net.sf.latexdraw.glib.views.synchroniser
Class ViewsSynchroniser

java.lang.Object
  extended by net.sf.latexdraw.glib.views.synchroniser.ViewsSynchroniser
Direct Known Subclasses:
PSTViewsSynchroniser

public abstract class ViewsSynchroniser
extends java.lang.Object

Defines an abstract synchroniser between a sets of Java2D views and other views.

This file is part of LaTeXDraw.
Copyright (c) 2005-2012 Arnaud BLOUIN

LaTeXDraw 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.
LaTeXDraw is distributed 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.

05/25/2010

Since:
3.0
Author:
Arnaud BLOUIN

Field Summary
protected  IDrawing drawing
          The shapes to synchronise.
protected  ViewsSynchroniserHandler handler
          The handler thats provides information to the synchroniser.
protected  java.util.Map<IShape,AbstractCodeView<?>> viewsCode
          The code views to synchronise.
 
Constructor Summary
ViewsSynchroniser(ViewsSynchroniserHandler h, IDrawing drawing)
          Creates and initialises the synchroniser.
 
Method Summary
 void clean()
          Removes the useless PSTricks views still in the synchroniser but removed from the drawing.
 IDrawing getDrawing()
           
 ViewsSynchroniserHandler getHandler()
           
 AbstractCodeView<?> getView(IShape shape)
           
 AbstractCodeView<?> getViewAt(int position)
           
 void setHandler(ViewsSynchroniserHandler handler)
           
 void setViews2D(IDrawing drawing)
           
abstract  void synchronise()
          Synchronises the Java2D views with their PSTricks views.
abstract  boolean updateCode(IShape shape)
          Updates the code corresponding to the given shape.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

handler

protected ViewsSynchroniserHandler handler
The handler thats provides information to the synchroniser.


drawing

protected IDrawing drawing
The shapes to synchronise.


viewsCode

protected java.util.Map<IShape,AbstractCodeView<?>> viewsCode
The code views to synchronise.

Constructor Detail

ViewsSynchroniser

public ViewsSynchroniser(ViewsSynchroniserHandler h,
                         IDrawing drawing)
Creates and initialises the synchroniser.

Parameters:
h - The handler.
drawing - The shapes to handle.
Throws:
java.lang.IllegalArgumentException - If the given views or handler is null.
Since:
3.0
Method Detail

synchronise

public abstract void synchronise()
Synchronises the Java2D views with their PSTricks views.

Since:
3.0

updateCode

public abstract boolean updateCode(IShape shape)
Updates the code corresponding to the given shape.

Parameters:
shape - The shape to updated.
Returns:
True if the code has been updated.
Since:
3.0

clean

public void clean()
Removes the useless PSTricks views still in the synchroniser but removed from the drawing. This method can take some times, so it is advised to launch it occasionally.

Since:
3.0

getView

public AbstractCodeView<?> getView(IShape shape)
Parameters:
shape - The shape that the researched view contains.
Returns:
The corresponding code view or null.
Since:
3.0

getViewAt

public AbstractCodeView<?> getViewAt(int position)
Parameters:
position - The position of the researched views.
Returns:
The corresponding code view at the given position or null.
Since:
3.0

getHandler

public ViewsSynchroniserHandler getHandler()
Returns:
The handler thats provides information to the synchroniser.
Since:
3.0

setHandler

public void setHandler(ViewsSynchroniserHandler handler)
Parameters:
handler - The new handler thats provides information to the synchroniser.
Since:
3.0

getDrawing

public IDrawing getDrawing()
Returns:
the drawing.
Since:
3.0

setViews2D

public void setViews2D(IDrawing drawing)
Parameters:
drawing - The drawing used to generate the code. Must not be null.
Since:
3.0