org.fraid.graphics
Class GraphicsStore

java.lang.Object
  extended by org.fraid.graphics.GraphicsStore

public abstract class GraphicsStore
extends java.lang.Object

A singleton which manages all open GraphicsPanels for the session. Can operate in two modes - Application or Applet.

See Also:
GraphicsPanel

Field Summary
protected static GraphicsStore sCorrectVersion
          Points to the particular instance which handles the requests.
protected static int sCounter
           
protected static boolean sExitCalled
          Internal flag which tels it to call System.exit() when the store gets empty (last GraphicsPanel is closed).
protected static java.lang.String sNegativeIndexStr
           
protected static java.lang.String sOutOfBoundsStr
           
protected static java.util.Hashtable<java.lang.Integer,GraphicsPanel> sStore
          The actual store.
 
Constructor Summary
GraphicsStore()
           
 
Method Summary
static int create()
          In Application mode each call to create() opens a new window.
static void exitWhenAllClosed()
          Call this if you want your application to exit automatically when the last GraphicsPanel is closed.
static GraphicsPanel getAt(int aIndex)
          Return the GraphicsPanel wtih this number.
static java.lang.Object[] getKeys()
           
static java.lang.Integer register(GraphicsPanel aPanel)
          This is how the GraphicsPanels register themselves.
static java.lang.Object remove(java.lang.Integer aKey)
          Remove the GraphicsPanel with the given number from the store.
static void setSizeAt(int aIndex, int aFrameWidth, int aFrameHeight)
          resize the window with the given id.
static void showAt(int aIndex, int aFrameWidth, int aFrameHeight)
          Make the GraphicsPanel with the given number visible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sCorrectVersion

protected static GraphicsStore sCorrectVersion
Points to the particular instance which handles the requests.


sStore

protected static java.util.Hashtable<java.lang.Integer,GraphicsPanel> sStore
The actual store.


sCounter

protected static int sCounter

sOutOfBoundsStr

protected static final java.lang.String sOutOfBoundsStr
See Also:
Constant Field Values

sNegativeIndexStr

protected static final java.lang.String sNegativeIndexStr
See Also:
Constant Field Values

sExitCalled

protected static boolean sExitCalled
Internal flag which tels it to call System.exit() when the store gets empty (last GraphicsPanel is closed).

Constructor Detail

GraphicsStore

public GraphicsStore()
Method Detail

getKeys

public static java.lang.Object[] getKeys()

getAt

public static GraphicsPanel getAt(int aIndex)
                           throws GraphicsStoreException
Return the GraphicsPanel wtih this number.

Parameters:
aIndex - an int value
Returns:
a GraphicsPanel value
Throws:
GraphicsStoreException - if an error occurs

create

public static int create()
In Application mode each call to create() opens a new window. In Applet mode each call to create() returns the last created window (largest number). If you need to open a GraphicsPanel in Applet mode, do it not with create() but manually (it will register itself automatically).

Returns:
the id for this panel at the store.

register

public static java.lang.Integer register(GraphicsPanel aPanel)
This is how the GraphicsPanels register themselves.

Parameters:
aPanel - a GraphicsPanel value
Returns:
an Integer value

remove

public static java.lang.Object remove(java.lang.Integer aKey)
Remove the GraphicsPanel with the given number from the store. You have to handle the removed instance yourself.

Parameters:
aKey - an Integer;
Returns:
the GraphicsPanel

showAt

public static void showAt(int aIndex,
                          int aFrameWidth,
                          int aFrameHeight)
                   throws GraphicsStoreException
Make the GraphicsPanel with the given number visible.

Parameters:
aIndex - the id of the panel;
aFrameWidth - an int value
aFrameHeight - an int value
Throws:
GraphicsStoreException - if an error occurs

setSizeAt

public static void setSizeAt(int aIndex,
                             int aFrameWidth,
                             int aFrameHeight)
                      throws GraphicsStoreException
resize the window with the given id.

Parameters:
aIndex - the id of the panel;
aFrameWidth - an int value
aFrameHeight - an int value
Throws:
GraphicsStoreException - if an error occurs

exitWhenAllClosed

public static void exitWhenAllClosed()
Call this if you want your application to exit automatically when the last GraphicsPanel is closed. Convenient for scripting. org.fraid,interpreter.Fraid.main(String[]) uses this.



Fraid (system and language). (C) 2003-2007 Ivaylo Iliev
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.