com.cosylab.vdct.graphics
Class DrawingSurface

java.lang.Object
  extended by com.cosylab.vdct.graphics.Decorator
      extended by com.cosylab.vdct.graphics.DrawingSurface
All Implemented Interfaces:
DrawingSurfaceInterface, LinkCommandInterface, VisualComponent, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.print.Pageable, java.awt.print.Printable, java.lang.Runnable, java.util.EventListener, javax.swing.event.MouseInputListener

public final class DrawingSurface
extends Decorator
implements DrawingSurfaceInterface, java.awt.print.Pageable, java.awt.print.Printable, javax.swing.event.MouseInputListener, java.lang.Runnable, LinkCommandInterface

Insert the type's description here. Creation date: (10.12.2000 13:19:16)

Author:
Matej Sekoranja

Field Summary
protected static java.lang.String untitledString
           
 
Fields inherited from interface java.awt.print.Pageable
UNKNOWN_NUMBER_OF_PAGES
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
DrawingSurface(java.lang.Object id, int serialNumber, InternalFrameInterface displayer, CopyContext copyContext)
          displayer can be null when no gui is linked to this.
 
Method Summary
 void addAction(ActionObject action)
          Insert the method's description here.
static void applyPortAndMacroConnectors(java.lang.Object dsId, DBData dbData, VDBData vdbData)
           
static java.util.HashMap applyVisualData(java.lang.Object dsId, boolean importDB, Group group, DBData dbData, VDBData vdbData)
          Insert the method's description here.
 void ascendFromTemplate()
          Insert the method's description here.
 void baseView()
          Insert the method's description here.
 void centerObject(VisibleObject object)
          Insert the method's description here.
 void checkForIncodedDBDs(java.io.File file)
          jh Creation date: (6.1.2001 22:35:40)
 boolean close()
           
 Macro createMacro(VDBMacro vdbMacro)
          Insert the method's description here.
 void createPort(VDBPort vdbPort)
          Insert the method's description here.
 void createTemplateInstance(java.lang.String name, java.lang.String type, boolean relative)
          Insert the method's description here.
 void descendIntoTemplate(Template template)
          Insert the method's description here.
 void draw(java.awt.Graphics g)
          Insert the method's description here.
 void generateMacros()
          Searches for undefined macros
 int getComponentHeight()
          Insert the method's description here.
 int getComponentWidth()
          Insert the method's description here.
 InternalFrameInterface getDisplayer()
           
 java.lang.Object getDsId()
           
 DSGUIInterface getGuimenu()
           
 int getNumberOfPages()
          Returns the number of pages in the set.
 java.awt.print.PageFormat getPageFormat(int pageIndex)
          Returns the PageFormat of the page specified by pageIndex.
 int getPressedX()
          Insert the method's description here.
 int getPressedY()
          Insert the method's description here.
 java.awt.print.Printable getPrintable(int pageIndex)
          Returns the Printable instance responsible for rendering the page specified by pageIndex.
 VDBTemplate getTemplate()
           
 java.util.Stack getTemplateStack()
          Returns the templateStack.
 java.lang.String getTitle()
           
 ViewState getView()
          Insert the method's description here.
 Group getViewGroup()
          Insert the method's description here.
 boolean importBorder(java.io.File file)
           
 boolean importDB(java.io.File file)
          SEPARATE DOWN CODE TO METHODS Creation date: (6.1.2001 22:35:40)
 boolean importFields(java.io.File file, boolean ignoreLinkFields)
          Import the fields from a .db file (option to ignore database link fields).
 void initializeWorkspace()
          Insert the method's description here.
 boolean isDisposed()
           
 boolean isFlat()
          Insert the method's description here.
 boolean isModified()
          Insert the method's description here.
 boolean isPrinting()
           
 boolean isTemplateAllowed(VDBTemplate template)
          Returns true if a template instance of the given template can be added as an element to currently edited template.
 boolean isTemplateChanged()
           
 void linkCommand(VisibleObject linkObject, LinkSource linkData)
          Insert the method's description here.
static void loadBlackOnWhiteColorScheme()
          Loads black on white color cheme
 boolean loadRdbDbGroup(javax.swing.JFrame guiContext)
           
static void loadWhiteOnBlackColorScheme()
          Loads white on black color cheme
 void mouseClicked(java.awt.event.MouseEvent e)
          Invoked when the mouse has been clicked on a component.
 void mouseDragged(java.awt.event.MouseEvent e)
          Invoked when a mouse button is pressed on a component and then dragged.
 void mouseEntered(java.awt.event.MouseEvent e)
          Invoked when the mouse enters a component.
 void mouseExited(java.awt.event.MouseEvent e)
          Invoked when the mouse exits a component.
 void mouseMoved(java.awt.event.MouseEvent e)
          Invoked when the mouse button has been moved on a component (with no buttons no down).
 void mousePressed(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been pressed on a component.
 void mouseReleased(java.awt.event.MouseEvent e)
          Invoked when a mouse button has been released on a component.
 void moveLevelUp()
          Insert the method's description here.
 void moveToGroup(Group group)
          Insert the method's description here.
 boolean open(java.io.File file)
          Insert the method's description here.
 boolean open(java.io.File file, boolean importDB)
          Insert the method's description here.
 boolean open(java.io.File file, boolean importDB, boolean importToCurrentGroup)
           
 boolean open(java.io.InputStream is, java.io.File file, boolean importDB, boolean importToCurrentGroup)
          SEPARATE DOWN CODE TO METHODS Creation date: (6.1.2001 22:35:40)
 boolean openDBD(java.io.File file)
          Insert the method's description here.
 boolean openDBD(java.io.File file, boolean importDBD)
          Insert the method's description here.
 boolean prepareTemplateLeave()
          true - OK, false - denied
 int print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
          Prints the page at the specified index into the specified Graphics context in the specified format.
 void recalculateNavigatorPosition()
          Insert the method's description here.
 boolean reloadTemplate(VDBTemplate data)
           
 void repaint()
          Insert the method's description here.
 void repaint(boolean drawOnlyHilitedOnce)
          Insert the method's description here.
 void reset()
           
 void resetDraggedPosition()
           
 void resize(int x0, int y0, int width, int height)
          Insert the method's description here.
 void run()
          DrawingSurface thread.
 boolean saveRdbGroup(javax.swing.JFrame guiContext, RdbDataId rdbId, boolean dialog)
           
 void setBlockNavigatorRedrawOnce(boolean blockNavigatorRedrawOnce)
          Sets the blockNavigatorRedrawOnce.
 void setDisposed(boolean disposed)
           
 void setModified(boolean newModified)
          Insert the method's description here.
 void setPressedMousePos(int x, int y)
           
 void setScale(double scale)
          Insert the method's description here.
 void templateReloadPostInit()
           
 void updateFile(java.io.File file)
           
 void updateWorkspaceGroup()
          Insert the method's description here.
 void updateWorkspaceScale()
          Insert the method's description here.
 void zoomArea(int x1, int y1, int x2, int y2)
          Insert the method's description here.
 
Methods inherited from class com.cosylab.vdct.graphics.Decorator
getComponent, setComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

untitledString

protected static final java.lang.String untitledString
See Also:
Constant Field Values
Constructor Detail

DrawingSurface

public DrawingSurface(java.lang.Object id,
                      int serialNumber,
                      InternalFrameInterface displayer,
                      CopyContext copyContext)
displayer can be null when no gui is linked to this.

Method Detail

addAction

public void addAction(ActionObject action)
Insert the method's description here. Creation date: (22.4.2001 18:44:03)

Parameters:
action - com.cosylab.vdct.undo.ActionObject

baseView

public void baseView()
Insert the method's description here. Creation date: (1.5.2001 17:32:20)


draw

public void draw(java.awt.Graphics g)
Insert the method's description here. Creation date: (10.12.2000 13:19:16)

Specified by:
draw in interface VisualComponent
Overrides:
draw in class Decorator

getComponentHeight

public int getComponentHeight()
Insert the method's description here. Creation date: (11.12.2000 16:23:31)

Specified by:
getComponentHeight in interface VisualComponent
Overrides:
getComponentHeight in class Decorator

getComponentWidth

public int getComponentWidth()
Insert the method's description here. Creation date: (11.12.2000 16:23:02)

Specified by:
getComponentWidth in interface VisualComponent
Overrides:
getComponentWidth in class Decorator
Returns:
int

getNumberOfPages

public int getNumberOfPages()
Returns the number of pages in the set. To enable advanced printing features, it is recommended that Pageable implementations return the true number of pages rather than the UNKNOWN_NUMBER_OF_PAGES constant.

Specified by:
getNumberOfPages in interface java.awt.print.Pageable
Returns:
the number of pages in this Pageable.

getPageFormat

public java.awt.print.PageFormat getPageFormat(int pageIndex)
                                        throws java.lang.IndexOutOfBoundsException
Returns the PageFormat of the page specified by pageIndex.

Specified by:
getPageFormat in interface java.awt.print.Pageable
Parameters:
pageIndex - the zero based index of the page whose PageFormat is being requested
Returns:
the PageFormat describing the size and orientation.
Throws:
IndexOutOfBoundsException - the Pageable does not contain the requested page.
java.lang.IndexOutOfBoundsException

getPressedX

public int getPressedX()
Insert the method's description here. Creation date: (3.2.2001 23:39:28)

Returns:
int

getPressedY

public int getPressedY()
Insert the method's description here. Creation date: (3.2.2001 23:39:28)

Returns:
int

resetDraggedPosition

public void resetDraggedPosition()

getPrintable

public java.awt.print.Printable getPrintable(int pageIndex)
                                      throws java.lang.IndexOutOfBoundsException
Returns the Printable instance responsible for rendering the page specified by pageIndex.

Specified by:
getPrintable in interface java.awt.print.Pageable
Parameters:
pageIndex - the zero based index of the page whose Printable is being requested
Returns:
the Printable that renders the page.
Throws:
IndexOutOfBoundsException - the Pageable does not contain the requested page.
java.lang.IndexOutOfBoundsException

getView

public ViewState getView()
Insert the method's description here. Creation date: (1.5.2001 17:55:20)

Returns:
com.cosylab.vdct.graphics.ViewState

getViewGroup

public Group getViewGroup()
Insert the method's description here. Creation date: (3.2.2001 22:58:19)

Returns:
com.cosylab.vdct.graphics.objects.Group

initializeWorkspace

public void initializeWorkspace()
Insert the method's description here. Creation date: (8.1.2001 18:04:49)


isFlat

public boolean isFlat()
Insert the method's description here. Creation date: (1.5.2001 17:51:29)

Returns:
boolean

isModified

public boolean isModified()
Insert the method's description here. Creation date: (1.2.2001 14:24:51)

Specified by:
isModified in interface DrawingSurfaceInterface
Returns:
boolean

linkCommand

public void linkCommand(VisibleObject linkObject,
                        LinkSource linkData)
Insert the method's description here. Creation date: (3.2.2001 13:31:09)

Specified by:
linkCommand in interface LinkCommandInterface

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Invoked when the mouse has been clicked on a component.

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Invoked when a mouse button is pressed on a component and then dragged. Mouse drag events will continue to be delivered to the component where the first originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Invoked when the mouse enters a component.

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Invoked when the mouse exits a component.

Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Invoked when the mouse button has been moved on a component (with no buttons no down).

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Invoked when a mouse button has been pressed on a component.

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Invoked when a mouse button has been released on a component.

Specified by:
mouseReleased in interface java.awt.event.MouseListener

moveLevelUp

public void moveLevelUp()
Insert the method's description here. Creation date: (28.1.2001 18:39:57)


open

public boolean open(java.io.File file)
             throws java.io.IOException
Insert the method's description here. Creation date: (6.1.2001 22:35:40)

Parameters:
file - java.io.File
Throws:
java.io.IOException

open

public boolean open(java.io.File file,
                    boolean importDB)
             throws java.io.IOException
Insert the method's description here. Creation date: (6.1.2001 22:35:40)

Specified by:
open in interface DrawingSurfaceInterface
Parameters:
file - java.io.File
Throws:
java.io.IOException

checkForIncodedDBDs

public void checkForIncodedDBDs(java.io.File file)
                         throws java.io.IOException
jh Creation date: (6.1.2001 22:35:40)

Throws:
java.io.IOException

importFields

public boolean importFields(java.io.File file,
                            boolean ignoreLinkFields)
Import the fields from a .db file (option to ignore database link fields). Only the fields of the records that are already defined in VDCT are overriden with the new settings. This would allow easy definition of the limits, hardware addresses, display range etc.


importBorder

public boolean importBorder(java.io.File file)

open

public boolean open(java.io.File file,
                    boolean importDB,
                    boolean importToCurrentGroup)
             throws java.io.IOException
Throws:
java.io.IOException

open

public boolean open(java.io.InputStream is,
                    java.io.File file,
                    boolean importDB,
                    boolean importToCurrentGroup)
             throws java.io.IOException
SEPARATE DOWN CODE TO METHODS Creation date: (6.1.2001 22:35:40)

Parameters:
file - java.io.File
Throws:
java.io.IOException

loadRdbDbGroup

public boolean loadRdbDbGroup(javax.swing.JFrame guiContext)

saveRdbGroup

public boolean saveRdbGroup(javax.swing.JFrame guiContext,
                            RdbDataId rdbId,
                            boolean dialog)

importDB

public boolean importDB(java.io.File file)
                 throws java.io.IOException
SEPARATE DOWN CODE TO METHODS Creation date: (6.1.2001 22:35:40)

Parameters:
file - java.io.File
Throws:
java.io.IOException

applyPortAndMacroConnectors

public static void applyPortAndMacroConnectors(java.lang.Object dsId,
                                               DBData dbData,
                                               VDBData vdbData)

applyVisualData

public static java.util.HashMap applyVisualData(java.lang.Object dsId,
                                                boolean importDB,
                                                Group group,
                                                DBData dbData,
                                                VDBData vdbData)
Insert the method's description here.


openDBD

public boolean openDBD(java.io.File file)
                throws java.io.IOException
Insert the method's description here. Creation date: (6.1.2001 22:35:40)

Parameters:
file - java.io.File
Throws:
java.io.IOException

openDBD

public boolean openDBD(java.io.File file,
                       boolean importDBD)
                throws java.io.IOException
Insert the method's description here. Creation date: (6.1.2001 22:35:40)

Parameters:
file - java.io.File
Throws:
java.io.IOException

print

public int print(java.awt.Graphics graphics,
                 java.awt.print.PageFormat pageFormat,
                 int pageIndex)
          throws java.awt.print.PrinterException
Prints the page at the specified index into the specified Graphics context in the specified format. A PrinterJob calls the Printable interface to request that a page be rendered into the context specified by graphics. The format of the page to be drawn is specified by pageFormat. The zero based index of the requested page is specified by pageIndex. If the requested page does not exist then this method returns NO_SUCH_PAGE; otherwise PAGE_EXISTS is returned. The Graphics class or subclass implements the PrinterGraphics interface to provide additional information. If the Printable object aborts the print job then it throws a PrinterException.

Specified by:
print in interface java.awt.print.Printable
Parameters:
graphics - the context into which the page is drawn
pageFormat - the size and orientation of the page being drawn
pageIndex - the zero based index of the page to be drawn
Returns:
PAGE_EXISTS if the page is rendered successfully or NO_SUCH_PAGE if pageIndex specifies a non-existent page.
Throws:
java.awt.print.PrinterException - thrown when the print job is terminated.

recalculateNavigatorPosition

public void recalculateNavigatorPosition()
Insert the method's description here. Creation date: (27.12.2000 15:04:17)


run

public void run()
DrawingSurface thread. Aim of this thread is to optimize drawing on the surface. It could happen that repaint() method is called very often (e.g. 100-times per second). Drawing at such rate is non-sence. The idea is to repaint whole workspace at maximum rate of 10 repaints/second.

Specified by:
run in interface java.lang.Runnable
See Also:
Runnable.run()

repaint

public void repaint(boolean drawOnlyHilitedOnce)
Insert the method's description here. Creation date: (25.12.2000 14:59:05)


repaint

public void repaint()
Insert the method's description here. Creation date: (25.12.2000 14:59:05)


resize

public void resize(int x0,
                   int y0,
                   int width,
                   int height)
Insert the method's description here. Creation date: (10.12.2000 13:19:16)

Specified by:
resize in interface VisualComponent
Overrides:
resize in class Decorator

setModified

public void setModified(boolean newModified)
Insert the method's description here. Creation date: (1.2.2001 14:24:51)

Parameters:
newModified - boolean

setScale

public void setScale(double scale)
Insert the method's description here. Creation date: (29.12.2000 12:40:13)

Parameters:
scale - double

centerObject

public void centerObject(VisibleObject object)
Insert the method's description here. Creation date: (29.12.2000 12:40:13)

Parameters:
scale - double

updateWorkspaceScale

public void updateWorkspaceScale()
Insert the method's description here. Creation date: (29.12.2000 12:49:54)


zoomArea

public void zoomArea(int x1,
                     int y1,
                     int x2,
                     int y2)
Insert the method's description here. Creation date: (25.12.2000 16:49:07)

Parameters:
x1 - int
y1 - int
x2 - int
y2 - int

createTemplateInstance

public void createTemplateInstance(java.lang.String name,
                                   java.lang.String type,
                                   boolean relative)
Insert the method's description here. Creation date: (3.2.2001 23:27:30)

Parameters:
name - java.lang.String
type - java.lang.String
relative - boolean

prepareTemplateLeave

public boolean prepareTemplateLeave()
true - OK, false - denied


templateReloadPostInit

public void templateReloadPostInit()

descendIntoTemplate

public void descendIntoTemplate(Template template)
Insert the method's description here. Creation date: (22.4.2001 18:44:03)

Parameters:
template - com.cosylab.vdct.graphics.objects.Template

ascendFromTemplate

public void ascendFromTemplate()
Insert the method's description here. Creation date: (22.4.2001 18:44:03)

Parameters:
template - com.cosylab.vdct.graphics.objects.Template

moveToGroup

public void moveToGroup(Group group)
Insert the method's description here. Creation date: (22.4.2001 18:44:03)

Parameters:
group - com.cosylab.vdct.graphics.objects.Group

updateWorkspaceGroup

public void updateWorkspaceGroup()
Insert the method's description here. Creation date: (22.4.2001 18:44:03)


getTemplateStack

public java.util.Stack getTemplateStack()
Returns the templateStack.

Returns:
Stack

reloadTemplate

public boolean reloadTemplate(VDBTemplate data)
Specified by:
reloadTemplate in interface DrawingSurfaceInterface

setBlockNavigatorRedrawOnce

public void setBlockNavigatorRedrawOnce(boolean blockNavigatorRedrawOnce)
Sets the blockNavigatorRedrawOnce.

Parameters:
blockNavigatorRedrawOnce - The blockNavigatorRedrawOnce to set

loadWhiteOnBlackColorScheme

public static void loadWhiteOnBlackColorScheme()
Loads white on black color cheme


loadBlackOnWhiteColorScheme

public static void loadBlackOnWhiteColorScheme()
Loads black on white color cheme


createPort

public void createPort(VDBPort vdbPort)
Insert the method's description here. Creation date: (3.2.2001 23:27:30)

Parameters:
name - java.lang.String

createMacro

public Macro createMacro(VDBMacro vdbMacro)
Insert the method's description here. Creation date: (3.2.2001 23:27:30)

Parameters:
name - java.lang.String

generateMacros

public void generateMacros()
Searches for undefined macros


isPrinting

public boolean isPrinting()

reset

public void reset()

setPressedMousePos

public void setPressedMousePos(int x,
                               int y)
Parameters:
pressedMousePosValid - the pressedMousePosValid to set

getGuimenu

public DSGUIInterface getGuimenu()
Returns:
the guimenu

getDsId

public java.lang.Object getDsId()
Specified by:
getDsId in interface DrawingSurfaceInterface
Returns:
the id

isDisposed

public boolean isDisposed()

setDisposed

public void setDisposed(boolean disposed)

updateFile

public void updateFile(java.io.File file)

getTitle

public java.lang.String getTitle()
Specified by:
getTitle in interface DrawingSurfaceInterface

close

public boolean close()
Specified by:
close in interface DrawingSurfaceInterface

getDisplayer

public InternalFrameInterface getDisplayer()

isTemplateChanged

public boolean isTemplateChanged()
Specified by:
isTemplateChanged in interface DrawingSurfaceInterface

getTemplate

public VDBTemplate getTemplate()
Specified by:
getTemplate in interface DrawingSurfaceInterface

isTemplateAllowed

public boolean isTemplateAllowed(VDBTemplate template)
Returns true if a template instance of the given template can be added as an element to currently edited template. Returns false if there is a cyclic template dependency.

Specified by:
isTemplateAllowed in interface DrawingSurfaceInterface