Back to index

moin  1.9.0~rc2
Public Member Functions | Static Public Attributes | Protected Member Functions | Static Package Attributes | Private Member Functions | Private Attributes | Static Private Attributes
CH.ifa.draw.appframe.DrawFrame Class Reference

Base class of drawing editor frames. More...

Collaboration diagram for CH.ifa.draw.appframe.DrawFrame:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DrawFrame (String title, Application application)
Application getApplication ()
void showStatus (String s)
void paletteUserSelected (PaletteButton button)
 Handles a user selection in the palette.
void paletteUserOver (PaletteButton button, boolean inside)
 Handles when the mouse enters or leaves a palette button.
Drawing drawing ()
 Gets the current drawing.
Tool tool ()
 Gets the current tool.
DrawingView view ()
 Gets the current drawing view.
void toolDone ()
 Sets the default tool of the editor.
void selectionChanged (DrawingView view)
 Handles a change of the current selection.

Static Public Attributes

static final String IMAGES = "images/"

Protected Member Functions

void populateMenuBar (MenuBar mb)
Panel createSouthPanel ()
 Creates the buttons panel.
void populateSouthPanel (Panel panel)
 Creates the buttons shown in the buttons panel.
CommandMenu createColorMenu (String attribute)
 Creates the color choice for the given attribute.
CommandMenu createFontMenu ()
 Creates the font choice.
Panel createEastPanel ()
void populateEastPanel (Panel panel)
Panel createNorthPanel ()
void populateNorthPanel (Panel panel)
Panel createWestPanel ()
 Creates the tools palette.
void populateWestPanel (Panel palette)
 Creates the tools.
Tool createSelectionTool ()
 Creates the selection tool used in this editor.
ToolButton createToolButton (String iconName, String toolName, Tool tool)
 Creates a tool button with the given image, tool, and text.
Drawing createDrawing ()
 Creates the drawing used in this application.
StandardDrawingView createDrawingView ()
 Creates the drawing view used in this application.
void loadDrawing (String param)
void setSimpleDisplayUpdate ()
void setBufferedDisplayUpdate ()
void showHelp ()
 Shows a help page for the application.

Static Package Attributes

static String fgUntitled = "untitled"

Private Member Functions

void initDrawing ()
void setTool (Tool t, String name)
void setSelected (ToolButton button)
void readDrawing (String filename)
void readFromStorableInput (String filename)
void readFromObjectInput (String filename)
String guessType (String file)

Private Attributes

transient Drawing fDrawing
transient Tool fTool
transient StandardDrawingView fView
transient ToolButton fDefaultToolButton
transient ToolButton fSelectedToolButton
transient boolean fSimpleUpdate
transient Button fUpdateButton
transient Panel fPanel
Iconkit fIconkit
Application fApplication

Static Private Attributes

static final String fgDrawPath = "/CH/ifa/draw/"

Detailed Description

Base class of drawing editor frames.

Provides support for drawing editors such that they are created in a Frame, so that all the facilities of AWT (such as Menus) are available. Provides basically the same facilities as a DrawApplet and is designed to be overridden to add extra menus and buttons.

Definition at line 30 of file DrawFrame.java.


Constructor & Destructor Documentation

CH.ifa.draw.appframe.DrawFrame.DrawFrame ( String  title,
Application  application 
) [inline]

Definition at line 54 of file DrawFrame.java.

                                                            {
       super(title);

       fApplication = application;

        fIconkit = new Iconkit(this);

       setLayout(new BorderLayout());

        fView = createDrawingView();

       MenuBar mb = new MenuBar();
        populateMenuBar(mb);
       setMenuBar(mb);

       Panel panel = createSouthPanel();
       if (panel != null) {
           populateSouthPanel(panel);
           add("South", panel);
       }

       panel = createWestPanel();
       if (panel != null) {
           populateWestPanel(panel);
           add("West", panel);
       }

       panel = createEastPanel();
       if (panel != null) {
           populateEastPanel(panel);
           add("East", panel);
       }

       panel = createNorthPanel();
       if (panel != null) {
           populateNorthPanel(panel);
           add("North", panel);
       }

       ScrollPane sp = new ScrollPane();
       sp.add(fView);
       add("Center", sp);

        initDrawing();
        setBufferedDisplayUpdate();
        //setupAttributes();
    }

Here is the call graph for this function:


Member Function Documentation

CommandMenu CH.ifa.draw.appframe.DrawFrame.createColorMenu ( String  attribute) [inline, protected]

Creates the color choice for the given attribute.

Definition at line 198 of file DrawFrame.java.

                                                            {
        CommandMenu menu = new CommandMenu("Colour");
       ColorMap map = ColorMap.getColorMap();
        for (int i = 0; i < map.size(); i++)
            menu.add(
                new ChangeAttributeCommand(
                    map.name(i), attribute,
                    map.color(i), fView));
        return menu;
    }
Drawing CH.ifa.draw.appframe.DrawFrame.createDrawing ( ) [inline, protected]

Creates the drawing used in this application.

You need to override this method to use a Drawing subclass in your application. By default a standard Drawing is returned.

Definition at line 291 of file DrawFrame.java.

                                      {
        return new StandardDrawing();
    }

Here is the caller graph for this function:

StandardDrawingView CH.ifa.draw.appframe.DrawFrame.createDrawingView ( ) [inline, protected]

Creates the drawing view used in this application.

You need to override this method to use a DrawingView subclass in your application. By default a standard DrawingView is returned.

Definition at line 301 of file DrawFrame.java.

                                                      {
        return new StandardDrawingView(this, 410, 370);
    }

Here is the caller graph for this function:

Panel CH.ifa.draw.appframe.DrawFrame.createEastPanel ( ) [inline, protected]

Definition at line 232 of file DrawFrame.java.

                                      {
       return null;
    }

Here is the caller graph for this function:

CommandMenu CH.ifa.draw.appframe.DrawFrame.createFontMenu ( ) [inline, protected]

Creates the font choice.

The choice is filled with all the fonts supported by the toolkit.

If we were able to assume 1.2 or greater, we would get the fonts list like this: String[] font = GraphicsEnvironment.getLocalGraphicsEnvironment(). getAvailableFontFamilyNames();

Definition at line 213 of file DrawFrame.java.

                                           {
        CommandMenu menu = new CommandMenu("Font");

        String fonts[] = Toolkit.getDefaultToolkit().getFontList();

        for (int i = 0; i < fonts.length; i++)
            menu.add(
              new ChangeAttributeCommand(
                  fonts[i], "FontName", fonts[i],  fView));
        return menu;
    }
Panel CH.ifa.draw.appframe.DrawFrame.createNorthPanel ( ) [inline, protected]

Definition at line 239 of file DrawFrame.java.

                                       {
       return null;
    }

Here is the caller graph for this function:

Creates the selection tool used in this editor.

Override to use a custom selection tool.

Definition at line 273 of file DrawFrame.java.

                                         {
        return new SelectionTool(fView);
    }

Here is the caller graph for this function:

Panel CH.ifa.draw.appframe.DrawFrame.createSouthPanel ( ) [inline, protected]

Creates the buttons panel.

Definition at line 116 of file DrawFrame.java.

                                       {
        Panel panel = new Panel();
        panel.setLayout(new PaletteLayout(2, new Point(2,2), false));
        return panel;
    }

Here is the caller graph for this function:

ToolButton CH.ifa.draw.appframe.DrawFrame.createToolButton ( String  iconName,
String  toolName,
Tool  tool 
) [inline, protected]

Creates a tool button with the given image, tool, and text.

Definition at line 280 of file DrawFrame.java.

                                                                 {
        return new ToolButton(this, iconName, toolName, tool);
    }

Here is the caller graph for this function:

Panel CH.ifa.draw.appframe.DrawFrame.createWestPanel ( ) [inline, protected]

Creates the tools palette.

Definition at line 249 of file DrawFrame.java.

                                      {
        Panel palette = new Panel();
        palette.setLayout(new PaletteLayout(2,new Point(2,2)));
        return palette;
    }

Here is the caller graph for this function:

Gets the current drawing.

See also:
DrawingEditor

Definition at line 330 of file DrawFrame.java.

                             {
        return fDrawing;
    }

Definition at line 102 of file DrawFrame.java.

                                        {
       return fApplication;
    }
String CH.ifa.draw.appframe.DrawFrame.guessType ( String  file) [inline, private]

Definition at line 450 of file DrawFrame.java.

                                          {
        if (file.endsWith(".draw"))
            return "storable";
        if (file.endsWith(".ser"))
            return "serialized";
        return "unknown";
    }

Here is the caller graph for this function:

void CH.ifa.draw.appframe.DrawFrame.initDrawing ( ) [inline, private]

Definition at line 368 of file DrawFrame.java.

                               {
        fDrawing = createDrawing();
        fView.setDrawing(fDrawing);
        toolDone();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.appframe.DrawFrame.loadDrawing ( String  param) [inline, protected]

Definition at line 392 of file DrawFrame.java.

                                             {
        if (param == fgUntitled) {
            fDrawing.release();
            initDrawing();
            return;
        }

        String filename = fApplication.getParameter(param);
        if (filename != null) {
           readDrawing(filename);
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.appframe.DrawFrame.paletteUserOver ( PaletteButton  button,
boolean  inside 
) [inline]

Handles when the mouse enters or leaves a palette button.

See also:
PaletteListener

Definition at line 319 of file DrawFrame.java.

                                                                      {
        if (inside)
            showStatus(((ToolButton) button).name());
        else
            showStatus(fSelectedToolButton.name());
    }

Here is the call graph for this function:

void CH.ifa.draw.appframe.DrawFrame.paletteUserSelected ( PaletteButton  button) [inline]

Handles a user selection in the palette.

See also:
PaletteListener

Definition at line 309 of file DrawFrame.java.

                                                          {
        ToolButton toolButton = (ToolButton) button;
        setTool(toolButton.tool(), toolButton.name());
        setSelected(toolButton);
    }

Here is the call graph for this function:

void CH.ifa.draw.appframe.DrawFrame.populateEastPanel ( Panel  panel) [inline, protected]

Definition at line 236 of file DrawFrame.java.

                                                  {
    }

Here is the caller graph for this function:

void CH.ifa.draw.appframe.DrawFrame.populateMenuBar ( MenuBar  mb) [inline, protected]

Definition at line 110 of file DrawFrame.java.

                                               {
    }

Here is the caller graph for this function:

void CH.ifa.draw.appframe.DrawFrame.populateNorthPanel ( Panel  panel) [inline, protected]

Definition at line 243 of file DrawFrame.java.

                                                   {
    }

Here is the caller graph for this function:

void CH.ifa.draw.appframe.DrawFrame.populateSouthPanel ( Panel  panel) [inline, protected]

Creates the buttons shown in the buttons panel.

Override to add additional/alternative buttons.

Parameters:
panelthe buttons panel.

Definition at line 127 of file DrawFrame.java.

                                                   {
        panel.add(new Filler(24,20));

        Choice drawingChoice = new Choice();
        drawingChoice.addItem(fgUntitled);

       String param = fApplication.getParameter("DRAWINGS");
       if (param == null)
           param = "";
              StringTokenizer st = new StringTokenizer(param);
        while (st.hasMoreTokens())
            drawingChoice.addItem(st.nextToken());
        // offer choice only if more than one
        if (drawingChoice.getItemCount() > 1)
            panel.add(drawingChoice);
        else
            panel.add(new Label(fgUntitled));

       drawingChoice.addItemListener(
           new ItemListener() {
                  public void itemStateChanged(ItemEvent e) {
                     if (e.getStateChange() == ItemEvent.SELECTED) {
                         loadDrawing((String)e.getItem());
                     }
                  }
              }
           );

        panel.add(new Filler(6,20));

        Button button;
        button = new CommandButton(new DeleteCommand("Delete", fView));
        panel.add(button);

        button = new CommandButton(new DuplicateCommand("Duplicate", fView));
        panel.add(button);

        button = new CommandButton(new GroupCommand("Group", fView));
        panel.add(button);

        button = new CommandButton(new UngroupCommand("Ungroup", fView));
        panel.add(button);

        button = new Button("Help");
       button.addActionListener(
           new ActionListener() {
                  public void actionPerformed(ActionEvent event) {
                     showHelp();
                  }
              }
           );
        panel.add(button);

       fUpdateButton = new Button("Simple Update");
       fUpdateButton.addActionListener(
           new ActionListener() {
                  public void actionPerformed(ActionEvent event) {
                     if (fSimpleUpdate)
                         setBufferedDisplayUpdate();
                     else
                         setSimpleDisplayUpdate();
                  }
              }
           );
       
       panel.add(fUpdateButton);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.appframe.DrawFrame.populateWestPanel ( Panel  palette) [inline, protected]

Creates the tools.

By default only the selection tool is added. Override this method to add additional tools. Call the inherited method to include the selection tool.

Parameters:
palettethe palette where the tools are added.

Definition at line 261 of file DrawFrame.java.

                                                    {
        Tool tool = createSelectionTool();

        fDefaultToolButton = createToolButton(
           IMAGES+"SEL", "Selection Tool", tool);
        palette.add(fDefaultToolButton);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.appframe.DrawFrame.readDrawing ( String  filename) [inline, private]

Definition at line 405 of file DrawFrame.java.

                                              {
        toolDone();
        String type = guessType(filename);
        if (type.equals("storable"))
            readFromStorableInput(filename);
        else if (type.equals("serialized"))
            readFromObjectInput(filename);
        else
            showStatus("Unknown file type");
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.appframe.DrawFrame.readFromObjectInput ( String  filename) [inline, private]

Definition at line 432 of file DrawFrame.java.

                                                      {
        try {
            URL url = fApplication.getURL(filename);
            InputStream stream = url.openStream();
            ObjectInput input = new ObjectInputStream(stream);
            fDrawing.release();
            fDrawing = (Drawing)input.readObject();
            fView.setDrawing(fDrawing);
        } catch (IOException e) {
            initDrawing();
            showStatus("Error reading (OI) " + filename + ": " + e);
           e.printStackTrace();
        } catch (ClassNotFoundException e) {
            initDrawing();
            showStatus("Class not found: " + e);
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.appframe.DrawFrame.readFromStorableInput ( String  filename) [inline, private]

Definition at line 416 of file DrawFrame.java.

                                                        {
        try {
            URL url = fApplication.getURL(filename);
            InputStream stream = url.openStream();
            StorableInput input = new StorableInput(stream);
            fDrawing.release();

            fDrawing = (Drawing)input.readStorable();
            fView.setDrawing(fDrawing);
        } catch (IOException e) {
            initDrawing();
            showStatus("Error reading " + filename + ": "+e);
           e.printStackTrace();
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.appframe.DrawFrame.selectionChanged ( DrawingView  view) [inline]

Handles a change of the current selection.

Updates all menu items that are selection sensitive.

See also:
DrawingEditor

Definition at line 364 of file DrawFrame.java.

                                                   {
        //setupAttributes();
    }

Definition at line 464 of file DrawFrame.java.

                                              {
        fView.setDisplayUpdate(new BufferedUpdateStrategy());
        fUpdateButton.setLabel("Buffered Update");
        fSimpleUpdate = false;
    }

Here is the caller graph for this function:

void CH.ifa.draw.appframe.DrawFrame.setSelected ( ToolButton  button) [inline, private]

Definition at line 384 of file DrawFrame.java.

                                                {
        if (fSelectedToolButton != null)
            fSelectedToolButton.reset();
        fSelectedToolButton = button;
        if (fSelectedToolButton != null)
            fSelectedToolButton.select();
    }

Here is the caller graph for this function:

Definition at line 458 of file DrawFrame.java.

                                            {
        fView.setDisplayUpdate(new SimpleUpdateStrategy());
        fUpdateButton.setLabel("Simple Update");
        fSimpleUpdate = true;
    }

Here is the caller graph for this function:

void CH.ifa.draw.appframe.DrawFrame.setTool ( Tool  t,
String  name 
) [inline, private]

Definition at line 374 of file DrawFrame.java.

                                              {
        if (fTool != null)
            fTool.deactivate();
        fTool = t;
        if (fTool != null) {
            showStatus(name);
            fTool.activate();
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.appframe.DrawFrame.showHelp ( ) [inline, protected]

Shows a help page for the application.

The URL of the help page is derived as follows: codeBase+applicationClassname+Help.html"

Definition at line 474 of file DrawFrame.java.

                              {
        try {
            String helpPath = getClass().getName().replace('.', '/');
            URL url = fApplication.getURL(helpPath + "Help.html");
            fApplication.popupFrame(url, "Help");
        } catch (IOException e) {
            showStatus("Help file not found");
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void CH.ifa.draw.appframe.DrawFrame.showStatus ( String  s) [inline]

Definition at line 106 of file DrawFrame.java.

Here is the call graph for this function:

Here is the caller graph for this function:

Gets the current tool.

See also:
DrawingEditor

Definition at line 338 of file DrawFrame.java.

                       {
        return fTool;
    }

Here is the caller graph for this function:

Sets the default tool of the editor.

See also:
DrawingEditor

Definition at line 354 of file DrawFrame.java.

Here is the call graph for this function:

Here is the caller graph for this function:

DrawingView CH.ifa.draw.appframe.DrawFrame.view ( ) [inline]

Gets the current drawing view.

See also:
DrawingEditor

Definition at line 346 of file DrawFrame.java.

                              {
        return fView;
    }

Member Data Documentation

Definition at line 52 of file DrawFrame.java.

transient ToolButton CH.ifa.draw.appframe.DrawFrame.fDefaultToolButton [private]

Definition at line 37 of file DrawFrame.java.

transient Drawing CH.ifa.draw.appframe.DrawFrame.fDrawing [private]

Definition at line 33 of file DrawFrame.java.

final String CH.ifa.draw.appframe.DrawFrame.fgDrawPath = "/CH/ifa/draw/" [static, private]

Definition at line 49 of file DrawFrame.java.

String CH.ifa.draw.appframe.DrawFrame.fgUntitled = "untitled" [static, package]

Definition at line 47 of file DrawFrame.java.

Definition at line 45 of file DrawFrame.java.

transient Panel CH.ifa.draw.appframe.DrawFrame.fPanel [private]

Definition at line 43 of file DrawFrame.java.

Definition at line 38 of file DrawFrame.java.

transient boolean CH.ifa.draw.appframe.DrawFrame.fSimpleUpdate [private]

Definition at line 40 of file DrawFrame.java.

transient Tool CH.ifa.draw.appframe.DrawFrame.fTool [private]

Definition at line 34 of file DrawFrame.java.

Definition at line 41 of file DrawFrame.java.

transient StandardDrawingView CH.ifa.draw.appframe.DrawFrame.fView [private]

Definition at line 36 of file DrawFrame.java.

final String CH.ifa.draw.appframe.DrawFrame.IMAGES = "images/" [static]

Definition at line 50 of file DrawFrame.java.


The documentation for this class was generated from the following file: