ini.trakem2.display
Class Displayable

java.lang.Object
  extended by ini.trakem2.persistence.DBObject
      extended by ini.trakem2.display.Displayable
All Implemented Interfaces:
Paintable
Direct Known Subclasses:
DLabel, LayerSet, Patch, Profile, ZDisplayable

public abstract class Displayable
extends DBObject
implements Paintable

The class that any element to be drawn on a Display must extend.


Nested Class Summary
protected static class Displayable.DataPackage
           
protected static class Displayable.DoEdit
          For any Displayable data, including: title, visible, locked, color, alpha, and a 'data' type which includes the actual data (points, areas, etc.) and the links,width,height, and transformation (since all the latter are correlated).
protected static class Displayable.DoEdits
           
protected static class Displayable.DoTransforms
           
protected  class Displayable.SliderListener
           
 
Field Summary
protected  float alpha
           
protected  java.lang.String annotation
           
protected  java.awt.geom.AffineTransform at
           
protected  java.awt.Color color
           
static byte COMPOSITE_ADD
           
static byte COMPOSITE_COLOR_YCBCR
           
static byte COMPOSITE_DIFFERENCE
           
static byte COMPOSITE_MULTIPLY
           
static byte COMPOSITE_NORMAL
           
static byte COMPOSITE_SUBTRACT
           
protected static java.lang.String[] compositeModes
           
protected  float height
          Width and height of the data, not the bounding box.
protected  java.util.HashSet<Displayable> hs_linked
          The Displayable objects this one is linked to.
protected static java.awt.Color last_color
           
protected  Layer layer
           
protected  java.util.Map<Displayable,java.util.Map<java.lang.String,java.lang.String>> linked_props
          The table of tables of properties: for any target Displayable, there is a set of properties specific of the relationship between this Displayable and the target one.
protected  java.util.Set<Displayable> linked_props_origins
          The call back hooks to remove any linked properties in other Displayable instances when this Displayable is removed.
protected  boolean locked
           
protected  java.util.Map<java.lang.String,java.lang.String> props
          The table of key/value property pairs of this Displayable.
protected static java.lang.String TAG_ATTR1
           
protected static java.lang.String TAG_ATTR2
           
protected  java.lang.String title
           
protected  boolean visible
           
protected  float width
          Width and height of the data, not the bounding box.
 
Fields inherited from class ini.trakem2.persistence.DBObject
id, project
 
Constructor Summary
Displayable(Project project, long id, java.util.HashMap<java.lang.String,java.lang.String> ht, java.util.HashMap<Displayable,java.lang.String> ht_links)
          Reconstruct a Displayable from an XML entry.
Displayable(Project project, long id, java.lang.String title, boolean locked, java.awt.geom.AffineTransform at, float width, float height)
          Reconstruct a Displayable from the database.
Displayable(Project project, java.lang.String title, double x, double y)
          The minimal public Displayable constructor.
 
Method Summary
 void adjustProperties()
          Shows a dialog to adjust properties of this object.
static boolean areThereLayerCrossLinks(java.util.Set<Layer> sublist, boolean ignore_stacks)
          Returns true if any Displayable objects of different layers in sublist are linked to each other.
 boolean canSendTo(Layer layer)
          Subclasses can specify the behaviour, for the default is true.
 Displayable clone()
          Performs a deep copy of this object.
 Displayable clone(Project pr)
          Performs a deep copy of this object but assigning to it the given project.
abstract  Displayable clone(Project pr, boolean copy_id)
          Performs a deep copy of this object, obtaining its unique id either from the given project or the exact same as this object's id.
protected static java.lang.String commonDTDChildren()
           
 boolean contains(int x_p, int y_p)
          Test whether the given point falls within the perimeter of this Displayable, considering the position x,y.
 boolean contains(Layer layer, int x_p, int y_p)
          Calls contains(x_p, y_p) unless overriden -- in ZDisplayable objects, it tests whether the given point is contained in the part of the ZDisplayable that shows in the given layer.
 void deselect()
          Tell this Displayable that is has been deselected from a Display.
 void destroy()
          Release resources.
static double[][] displacePoints(double[][] p, double dx, double dy)
           
static void exportDTD(java.lang.StringBuilder sb_header, java.util.HashSet<java.lang.String> hs, java.lang.String indent)
           
static void exportDTD(java.lang.String type, java.lang.StringBuilder sb_header, java.util.HashSet<java.lang.String> hs, java.lang.String indent)
          Adds simply DTD !ATTRIBUTE tags.
 void exportSVG(java.lang.StringBuffer data, double z_scale, java.lang.String indent)
          Does nothing unless overriden.
 void exportXML(java.lang.StringBuilder sb_body, java.lang.String in, java.lang.Object any)
          The oid is this objects' id, whereas the 'id' tag will be the id of the wrapper Thing object.
 DBObject findById(long id)
           
protected static int findNearestPoint(double[][] a, int n_points, double x_p, double y_p)
          Fine nearest point in array a, from 0 up to n_points, to point x_p,y_p.
protected static int findNearestPoint(double[][] a, long[] p_layer, int n_points, double x_p, double y_p, long lid)
           
 java.awt.geom.AffineTransform getAffineTransform()
           
 java.awt.geom.AffineTransform getAffineTransformCopy()
           
 float getAlpha()
           
 java.lang.String getAnnotation()
          Returns null if none.
 java.awt.geom.Area getArea()
           
 java.awt.geom.Area getAreaAt(Layer layer)
          This area is meant to represent the entire area where a Displayable paints to in the @param layer.
protected  java.awt.geom.Area getAreaForBucket(Layer layer)
          Should call getAreaAt(layer), or methods that are similar but faster.
 java.awt.Rectangle getBoundingBox()
          Bounding box of the transformed data.
static java.awt.Rectangle getBoundingBox(java.util.Collection<? extends Displayable> ds, java.awt.Rectangle r)
          Bounding box of a collection of transformed Displayables If the list is empty, there is no bounding box, so it returns null.
 java.awt.Rectangle getBoundingBox(java.awt.Rectangle r)
          Bounding box of the transformed data.
protected  java.awt.Rectangle getBounds(java.awt.Rectangle r)
          Bounding box of the transformed data (or 0,0,0,0 when no data).
 java.awt.Rectangle getBounds(java.awt.Rectangle r, Layer layer)
          Will fill bounding box values into given rectangle -- only that part of this object showing in the given layer will be included in the box.
 Bucketable getBucketable()
           
 java.awt.Color getColor()
           
protected  java.awt.Composite getComposite(byte mode)
           
static java.awt.Composite getComposite(byte mode, float alpha)
           
 byte getCompositeMode()
           
 float getHeight()
          Returns the height of the data.
 java.awt.geom.Area getIntersection(Displayable d)
          Returns the intersection of this Displayable's area with the given one.
 Layer getLayer()
           
 java.util.Collection<java.lang.Long> getLayerIds()
           
 LayerSet getLayerSet()
           
 java.util.Collection<Layer> getLayersWithData()
          Override it to provide Layer pointers directly.
 java.util.HashSet<Displayable> getLinked()
          Return the HashSet of directly linked Displayable objects.
 java.util.HashSet<Displayable> getLinked(java.lang.Class<?> c)
          Return those of Class c from among the directly linked.
 java.awt.Rectangle getLinkedBox(boolean same_layer)
          Returns the sum of bounding boxes of all linked Displayables.
 java.util.HashSet<Displayable> getLinkedGroup(java.util.HashSet<Displayable> hs)
          Return the HashSet of all directly and indirectly linked objects.
 java.util.Map<Displayable,java.util.Map<java.lang.String,java.lang.String>> getLinkedProperties()
          Returns a copy of this object's linked properties, which may be empty.
 java.util.Map<java.lang.String,java.lang.String> getLinkedProperties(Displayable target)
          Returns a copy of this object's linked properties table for the given Displayable, which may be empty.
 java.lang.String getLinkedProperty(Displayable target, java.lang.String key)
          If the key is null or not found, or the aren't any properties linked to the target, returns null; otherwise returns the stored value for key and target.
 java.lang.String getLinkedProperty(Displayable target, java.lang.String key, java.lang.String default_value)
          If the key is null or not found, or the aren't any properties linked to the target, returns default_value; otherwise returns the stored value for key and target.
static java.awt.Rectangle getMinimalBoundingBox(Displayable[] d)
           
protected  double getNameId()
          If the title is purely numeric, returns it as a double; otherwise returns 0.
 java.awt.Polygon getPerimeter()
          Subclasses can override this method to provide the exact contour, otherwise it returns the transformed bounding box of the data.
 java.awt.Polygon getPerimeter(int w, int n, int e, int s)
          Returns the perimeter enlarged in all West, North, East and South directions, in pixels.
 java.util.Map<java.lang.String,java.lang.String> getProperties()
          Returns a copy of this object's properties, or null if none.
 java.lang.String getProperty(java.lang.String key)
          If key is null or not found, returns null; otherwise returns the stored value for key.
 java.lang.String getProperty(java.lang.String key, java.lang.String default_value)
          If key is null or not found, returns default_value; otherwise returns the stored value for key.
 java.lang.String getShortTitle()
          Sublcasses can override this method to provide a proper String, otherwise calls getTitle()
 java.lang.String getTitle()
          Sublcasses can override this method to provide a proper String, otherwise calls toString()
 float getWidth()
          Returns the width of the data.
 int getX()
          Returns the x of the bounding box.
static java.lang.String getXMLSafeValue(java.util.Map.Entry<java.lang.String,java.lang.String> e, java.lang.String value)
          Make sure the value is valid for an XML attribute content inside double quotes.
static java.lang.String getXMLSafeValue(java.lang.String value)
           
 int getY()
          Returns the y of the bounding box.
 boolean hasLinkedGroupWithinLayer(Layer la)
           
 boolean hasProperties()
           
 boolean intersects(java.awt.geom.Area area)
           
 boolean intersects(Displayable d)
          Check if this perimeter's intersects that of the given Displayable.
 boolean intersects(Layer layer, java.awt.geom.Area area)
          Calls intersects(area) unless overriden -- intended for ZDisplayable objects to return whether they intersect the given area at the given layer.
 boolean intersects(Layer layer, java.awt.Rectangle r)
           
 java.awt.geom.Point2D.Double inverseTransformPoint(double px, double py)
           
abstract  boolean isDeletable()
           
 boolean isLinked()
          Check if this object is directly linked to any other Displayable objects.
 boolean isLinked(java.lang.Class<?> c)
          Check if this object is directly linked to a Displayable object of the given Class.
 boolean isLinked(Displayable d)
          Check if thisobject is directly linked to the given Displayable.
 boolean isLocked()
          Check if this or any of the Displayables in the linked group is locked.
 boolean isLocked2()
          Return the value of the field 'locked'.
 boolean isOnlyLinkedTo(java.lang.Class<?> c)
          Check if this object is directly linked only to Displayable objects of the given class (returns true) or to none (returns true as well).
 boolean isOnlyLinkedTo(java.lang.Class<?> c, Layer layer)
          Check if this object is directly linked only to Displayable objects of the given class in the same layer (returns true).
 boolean isOutOfRepaintingClip(double magnification, java.awt.Rectangle srcRect, java.awt.Rectangle clipRect)
           
 boolean isOutOfRepaintingClip(java.awt.Rectangle clipRect, double scale)
          For the DisplayNavigator.
protected  boolean isRoughlyInside(Layer layer, java.awt.Rectangle r)
          If this Displayable intersects with @param r or almost intersects, then returns true.
 boolean isVisible()
           
 void keyPressed(java.awt.event.KeyEvent ke)
           
 void link(Displayable d)
          Link the given Displayable with this Displayable, and then tell the given Displayable to link this.
 void link(Displayable d, boolean update_database)
          Link the given Displayable with this Displayable, and then tell the given Displayable to link this.
 boolean linkPatches()
          Link the Patch objects that lay underneath the bounding box of this Displayable, so that they cannot be dragged independently.
protected  ij.gui.GenericDialog makeAdjustPropertiesDialog()
           
 ij.measure.ResultsTable measure(ij.measure.ResultsTable rt)
          Does nothing unless overriden.
 void mouseDragged(java.awt.event.MouseEvent me, Layer layer, int x_p, int y_p, int x_d, int y_d, int x_d_old, int y_d_old)
           
 void mousePressed(java.awt.event.MouseEvent me, Layer layer, int x_p, int y_p, double mag)
           
 void mouseReleased(java.awt.event.MouseEvent me, Layer layer, int x_p, int y_p, int x_d, int y_d, int x_r, int y_r)
           
 void mouseWheelMoved(java.awt.event.MouseWheelEvent mwe)
          Does nothing unless overriden.
 void paint(java.awt.Graphics2D g, java.awt.Rectangle srcRect, double magnification, boolean active, int channels, Layer active_layer, java.util.List<Layer> layers)
           
 void paintAsBox(java.awt.Graphics2D g)
           
 void paintOffscreen(java.awt.Graphics2D g, java.awt.Rectangle srcRect, double magnification, boolean active, int channels, Layer active_layer, java.util.List<Layer> layers)
          Paints waiting for data to load, if necessary.
 void paintSnapshot(java.awt.Graphics2D g, Layer layer, java.util.List<Layer> layers, java.awt.Rectangle srcRect, double mag)
           
 void prePaint(java.awt.Graphics2D g, java.awt.Rectangle srcRect, double magnification, boolean active, int channels, Layer active_layer, java.util.List<Layer> layers)
           
 void preTransform(java.awt.geom.AffineTransform affine, boolean linked)
          preConcatenate the given affine transform to this Displayable's affine.
protected  Displayable.DoEdit processAdjustPropertiesDialog(ij.gui.GenericDialog gd)
           
 boolean remove(boolean check)
          Remove from both the database and any Display that shows the Layer in which this Displayable is shown.
protected  boolean remove2(boolean check)
          Remove also from the trees if present; does nothing more than remove(boolean) unless overriden.
 java.util.Map<java.lang.String,java.lang.String> removeLinkedProperties(Displayable target)
          Removes and returns the table of properties lined to the target Displayable.
protected  void removeLinkedPropertiesFromOrigins()
          Tell any other Displayable that has a linked property with this Displayable to remove it.
 void repaint()
          Repaint this Displayable in all Display instances that are showing it.
protected  void restXML(java.lang.StringBuilder sb_body, java.lang.String in, java.lang.Object any)
          Add properties, links, etc.
 void rotate(double radians, double xo, double yo)
          Rotate relative to an anchor point.
 void rotate(double radians, double xo, double yo, boolean linked)
          Rotate relative to an anchor point.
static double[][] rotatePoints(double[][] p, double rot, double xo, double yo)
          Rotate 2D points relative to the given pivot point by the given rot angle (in radians), in the 2D plane.
 void scale(double sx, double sy, double xo, double yo)
          Scale relative to an anchor point (will translate as necessary).
 void scale(double sx, double sy, double xo, double yo, boolean linked)
          Scale relative to an anchor point (will translate as necessary).
static double[][] scalePoints(double[][] p, double sx, double sy, double xo, double yo)
          Scale 2D points relative to the given pivot point xo,yo.
 void setAffineTransform(java.awt.geom.AffineTransform at)
          Sets the matrix values of this Displayable's AffineTransform to those of the given AffineTransform.
 void setAlpha(float alpha)
           
protected  void setAlpha(float alpha, boolean update)
           
 void setAnnotation(java.lang.String annotation)
           
 void setColor(java.awt.Color color)
           
 void setCompositeMode(byte mode)
          Sets the composite mode, which determines how is this image painted to the screen relative to the other images.
 void setDimensions(double width, double height)
          Not accepted if zero or negative.
 void setDimensions(double width, double height, boolean repaint)
          Sets the dimensions of the bounding box.
 void setLayer(Layer layer)
           
 void setLayer(Layer layer, boolean update_db)
           
 void setLinkedProperties(Displayable target, java.util.Map<java.lang.String,java.lang.String> p)
          Add all the properties in map p as properties linked to the target Displayable.
 boolean setLinkedProperty(Displayable target, java.lang.String key, java.lang.String value)
          Add a property that is specific to the relationship between this Displayable and the target, and will be deleted when the target Displayable is deleted.
 void setLocation(double x, double y)
          Sets the top left of the bounding box to x,y.
 void setLocked(boolean lock)
          Set the locking state of this Displayable, which affects that of its linked Displayable objects.
 boolean setProperty(java.lang.String key, java.lang.String value)
          Set a key/valye property pair; to remove a property, set the value to null.
 void setTitle(java.lang.String title)
          Does not accept null or zero-length titles.
 void setVisible(boolean visible)
           
 void setVisible(boolean visible, boolean repaint)
           
 void snapTo(int cx, int cy, int x_p, int y_p)
          Does nothing unless overriden.
 boolean softRemove()
          Calls remove(false) unless overriden.
 java.lang.String toString()
          Minimal info that identifies this object as unique, for display on a JTree node.
 void transform(java.awt.geom.AffineTransform at)
          Concatenate the given affine to this and all its linked objects.
static void transformPoint(double[][] p, int i, double dx, double dy, double rot, double xo, double yo)
          Transform in place only the 'i' point in the points array.
 java.awt.geom.Point2D.Double transformPoint(double px, double py)
          Apply this Displayable's AffineTransform to the given point.
protected static double[] transformPoints(java.awt.geom.AffineTransform aff, double[] p)
           
protected static double[][] transformPoints(java.awt.geom.AffineTransform aff, double[][] p, int length)
          Will crop second dimension of the given array at the given length.
protected  double[] transformPoints(double[] p)
          Transforms the points represented as X1,Y1,X2,Y2...
 double[][] transformPoints(double[][] p)
          Returns the argument if this Displayable's AffineTransform is the identity; otherwise returns a new double[][] with all points from @param p transformed according to the AffineTransform.
 double[][] transformPoints(double[][] p, java.awt.geom.AffineTransform additional)
           
protected  double[][] transformPoints(double[][] p, int length)
           
protected  double[][] transformPoints(double[][] p, int length, java.awt.geom.AffineTransform additional)
          Will crop second dimension of the given array at the given length.
protected  double[] transformPoints(double[] p, java.awt.geom.AffineTransform additional)
           
protected  float[] transformPoints(float[] p)
          Transforms the points represented as X1,Y1,X2,Y2...
 java.awt.Rectangle transformRectangle(java.awt.Rectangle r)
          Returns a new Rectangle which encloses completly the given rectangle after transforming it with this Displayable's AffineTransform.
 void translate(double dx, double dy)
           
 void translate(double dx, double dy, boolean linked)
          Translate this Displayable and its linked ones if linked=true.
 void unlink()
          Remove all links held by this Displayable.
 void unlink(Displayable d)
          Remove the link with the given Displayable, and tell the given Displayable to remove the link with this.
 void unlinkAll(java.lang.Class<?> c)
          Unlink all Displayable objects of the given type linked by this.
 void updateBucket()
          Commands the parent container (a Layer or a LayerSet) to update the bucket position of this Displayable.
 boolean updateInDatabase(java.lang.String key)
           
protected static void xmlError(DBObject dbo, java.lang.String tag, java.lang.Object default_value)
           
protected  void xmlError(java.lang.String tag, java.lang.Object default_value)
           
 
Methods inherited from class ini.trakem2.persistence.DBObject
addToDatabase, getId, getInfo, getProject, getUniqueIdentifier, removeFromDatabase, updateInDatabase
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

compositeModes

protected static final java.lang.String[] compositeModes

COMPOSITE_NORMAL

public static final byte COMPOSITE_NORMAL
See Also:
Constant Field Values

COMPOSITE_ADD

public static final byte COMPOSITE_ADD
See Also:
Constant Field Values

COMPOSITE_SUBTRACT

public static final byte COMPOSITE_SUBTRACT
See Also:
Constant Field Values

COMPOSITE_MULTIPLY

public static final byte COMPOSITE_MULTIPLY
See Also:
Constant Field Values

COMPOSITE_DIFFERENCE

public static final byte COMPOSITE_DIFFERENCE
See Also:
Constant Field Values

COMPOSITE_COLOR_YCBCR

public static final byte COMPOSITE_COLOR_YCBCR
See Also:
Constant Field Values

at

protected final java.awt.geom.AffineTransform at

width

protected float width
Width and height of the data, not the bounding box. If the AffineTransform is different than identity, then the bounding box will be different.


height

protected float height
Width and height of the data, not the bounding box. If the AffineTransform is different than identity, then the bounding box will be different.


locked

protected boolean locked

title

protected java.lang.String title

annotation

protected java.lang.String annotation

last_color

protected static java.awt.Color last_color

color

protected java.awt.Color color

alpha

protected float alpha

visible

protected boolean visible

layer

protected Layer layer

hs_linked

protected java.util.HashSet<Displayable> hs_linked
The Displayable objects this one is linked to. Can be null.


props

protected java.util.Map<java.lang.String,java.lang.String> props
The table of key/value property pairs of this Displayable.


linked_props

protected java.util.Map<Displayable,java.util.Map<java.lang.String,java.lang.String>> linked_props
The table of tables of properties: for any target Displayable, there is a set of properties specific of the relationship between this Displayable and the target one.


linked_props_origins

protected java.util.Set<Displayable> linked_props_origins
The call back hooks to remove any linked properties in other Displayable instances when this Displayable is removed.


TAG_ATTR1

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

TAG_ATTR2

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

Displayable

public Displayable(Project project,
                   java.lang.String title,
                   double x,
                   double y)
The minimal public Displayable constructor.


Displayable

public Displayable(Project project,
                   long id,
                   java.lang.String title,
                   boolean locked,
                   java.awt.geom.AffineTransform at,
                   float width,
                   float height)
Reconstruct a Displayable from the database.


Displayable

public Displayable(Project project,
                   long id,
                   java.util.HashMap<java.lang.String,java.lang.String> ht,
                   java.util.HashMap<Displayable,java.lang.String> ht_links)
Reconstruct a Displayable from an XML entry. Used entries get removed from the HashMap.

Method Detail

getCompositeMode

public byte getCompositeMode()

getComposite

protected java.awt.Composite getComposite(byte mode)

setCompositeMode

public void setCompositeMode(byte mode)
Sets the composite mode, which determines how is this image painted to the screen relative to the other images. For example, a 16-bit image with a red LUT may be set, with the COMPOSITE_COLOR_YCBCR mode, to contribute towards the red channel only of an underlying set of grayscale electron microscopy images.

Parameters:
mode - Any of the COMPOSITE_* modes available.
Throws:
java.lang.IllegalArgumentException - if the is not valid.

getComposite

public static java.awt.Composite getComposite(byte mode,
                                              float alpha)

setProperty

public boolean setProperty(java.lang.String key,
                           java.lang.String value)
Set a key/valye property pair; to remove a property, set the value to null.


getProperty

public java.lang.String getProperty(java.lang.String key)
If key is null or not found, returns null; otherwise returns the stored value for key.


getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String default_value)
If key is null or not found, returns default_value; otherwise returns the stored value for key.


getProperties

public java.util.Map<java.lang.String,java.lang.String> getProperties()
Returns a copy of this object's properties, or null if none.


hasProperties

public boolean hasProperties()

setLinkedProperty

public boolean setLinkedProperty(Displayable target,
                                 java.lang.String key,
                                 java.lang.String value)
Add a property that is specific to the relationship between this Displayable and the target, and will be deleted when the target Displayable is deleted.


setLinkedProperties

public void setLinkedProperties(Displayable target,
                                java.util.Map<java.lang.String,java.lang.String> p)
Add all the properties in map p as properties linked to the target Displayable. If any keys already existed their values will be overwritten by those in p. Any keys whose value is null will be removed.


removeLinkedProperties

public java.util.Map<java.lang.String,java.lang.String> removeLinkedProperties(Displayable target)
Removes and returns the table of properties lined to the target Displayable. May be empty.


removeLinkedPropertiesFromOrigins

protected void removeLinkedPropertiesFromOrigins()
Tell any other Displayable that has a linked property with this Displayable to remove it.


getLinkedProperty

public java.lang.String getLinkedProperty(Displayable target,
                                          java.lang.String key)
If the key is null or not found, or the aren't any properties linked to the target, returns null; otherwise returns the stored value for key and target.


getLinkedProperty

public java.lang.String getLinkedProperty(Displayable target,
                                          java.lang.String key,
                                          java.lang.String default_value)
If the key is null or not found, or the aren't any properties linked to the target, returns default_value; otherwise returns the stored value for key and target.


getLinkedProperties

public java.util.Map<java.lang.String,java.lang.String> getLinkedProperties(Displayable target)
Returns a copy of this object's linked properties table for the given Displayable, which may be empty.


getLinkedProperties

public java.util.Map<Displayable,java.util.Map<java.lang.String,java.lang.String>> getLinkedProperties()
Returns a copy of this object's linked properties, which may be empty.


setLocked

public void setLocked(boolean lock)
Set the locking state of this Displayable, which affects that of its linked Displayable objects. If lock is true, this Displayable is set as locked; any linked Displayable's locked state is not changed, but will behave as locked. If lock is false, this Displayable and all its linked Displayable objects are set as unlocked.


isLocked2

public boolean isLocked2()
Return the value of the field 'locked'.


isLocked

public boolean isLocked()
Check if this or any of the Displayables in the linked group is locked.


xmlError

protected final void xmlError(java.lang.String tag,
                              java.lang.Object default_value)

xmlError

protected static final void xmlError(DBObject dbo,
                                     java.lang.String tag,
                                     java.lang.Object default_value)

paint

public void paint(java.awt.Graphics2D g,
                  java.awt.Rectangle srcRect,
                  double magnification,
                  boolean active,
                  int channels,
                  Layer active_layer,
                  java.util.List<Layer> layers)
Specified by:
paint in interface Paintable

prePaint

public void prePaint(java.awt.Graphics2D g,
                     java.awt.Rectangle srcRect,
                     double magnification,
                     boolean active,
                     int channels,
                     Layer active_layer,
                     java.util.List<Layer> layers)
Specified by:
prePaint in interface Paintable

paintOffscreen

public void paintOffscreen(java.awt.Graphics2D g,
                           java.awt.Rectangle srcRect,
                           double magnification,
                           boolean active,
                           int channels,
                           Layer active_layer,
                           java.util.List<Layer> layers)
Paints waiting for data to load, if necessary.


setDimensions

public void setDimensions(double width,
                          double height)
Not accepted if zero or negative. Remakes the snapshot, updates the snapshot panel and the Display.


setDimensions

public void setDimensions(double width,
                          double height,
                          boolean repaint)
Sets the dimensions of the bounding box. Not accepted if zero or negative. If repaint is true, remakes the snapshot, updates the snapshot panel and the Display.


setLayer

public void setLayer(Layer layer,
                     boolean update_db)

setLayer

public void setLayer(Layer layer)

getLayer

public Layer getLayer()

setTitle

public void setTitle(java.lang.String title)
Does not accept null or zero-length titles.


getTitle

public java.lang.String getTitle()
Description copied from class: DBObject
Sublcasses can override this method to provide a proper String, otherwise calls toString()

Overrides:
getTitle in class DBObject

getShortTitle

public java.lang.String getShortTitle()
Description copied from class: DBObject
Sublcasses can override this method to provide a proper String, otherwise calls getTitle()

Overrides:
getShortTitle in class DBObject

getX

public int getX()
Returns the x of the bounding box.


getY

public int getY()
Returns the y of the bounding box.


getWidth

public float getWidth()
Returns the width of the data.


getHeight

public float getHeight()
Returns the height of the data.


getBoundingBox

public java.awt.Rectangle getBoundingBox()
Bounding box of the transformed data.


getBounds

public java.awt.Rectangle getBounds(java.awt.Rectangle r,
                                    Layer layer)
Will fill bounding box values into given rectangle -- only that part of this object showing in the given layer will be included in the box. If @param r is null, returns a new Rectangle; else, sets the bounds into @param r and returns it. If there aren't any bounds for this object at @param layer, returns either @param r with zero width and zero height, or a new Rectangle with zero width and zero height. Never returns null.


getBoundingBox

public java.awt.Rectangle getBoundingBox(java.awt.Rectangle r)
Bounding box of the transformed data. Saves one Rectangle allocation, returns the same Rectangle, modified (or a new one if null).


getBounds

protected java.awt.Rectangle getBounds(java.awt.Rectangle r)
Bounding box of the transformed data (or 0,0,0,0 when no data). Returns the same Rectangle, modified.


getBoundingBox

public static java.awt.Rectangle getBoundingBox(java.util.Collection<? extends Displayable> ds,
                                                java.awt.Rectangle r)
Bounding box of a collection of transformed Displayables If the list is empty, there is no bounding box, so it returns null.


getPerimeter

public java.awt.Polygon getPerimeter()
Subclasses can override this method to provide the exact contour, otherwise it returns the transformed bounding box of the data.


getPerimeter

public java.awt.Polygon getPerimeter(int w,
                                     int n,
                                     int e,
                                     int s)
Returns the perimeter enlarged in all West, North, East and South directions, in pixels.


contains

public boolean contains(int x_p,
                        int y_p)
Test whether the given point falls within the perimeter of this Displayable, considering the position x,y. Used by the DisplayCanvas mouse events.


contains

public boolean contains(Layer layer,
                        int x_p,
                        int y_p)
Calls contains(x_p, y_p) unless overriden -- in ZDisplayable objects, it tests whether the given point is contained in the part of the ZDisplayable that shows in the given layer.


setAlpha

public void setAlpha(float alpha)

setAlpha

protected void setAlpha(float alpha,
                        boolean update)

getAlpha

public float getAlpha()

getColor

public java.awt.Color getColor()

getLinked

public java.util.HashSet<Displayable> getLinked()
Return the HashSet of directly linked Displayable objects.


getLinked

public java.util.HashSet<Displayable> getLinked(java.lang.Class<?> c)
Return those of Class c from among the directly linked.


getLinkedGroup

public java.util.HashSet<Displayable> getLinkedGroup(java.util.HashSet<Displayable> hs)
Return the HashSet of all directly and indirectly linked objects. When no links, then the HashSet contains only this Displayable.


mousePressed

public void mousePressed(java.awt.event.MouseEvent me,
                         Layer layer,
                         int x_p,
                         int y_p,
                         double mag)

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent me,
                         Layer layer,
                         int x_p,
                         int y_p,
                         int x_d,
                         int y_d,
                         int x_d_old,
                         int y_d_old)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me,
                          Layer layer,
                          int x_p,
                          int y_p,
                          int x_d,
                          int y_d,
                          int x_r,
                          int y_r)

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent mwe)
Does nothing unless overriden.


keyPressed

public void keyPressed(java.awt.event.KeyEvent ke)

isVisible

public boolean isVisible()

setVisible

public final void setVisible(boolean visible)

setVisible

public void setVisible(boolean visible,
                       boolean repaint)

repaint

public void repaint()
Repaint this Displayable in all Display instances that are showing it.


setColor

public void setColor(java.awt.Color color)

destroy

public void destroy()
Release resources.


isOutOfRepaintingClip

public boolean isOutOfRepaintingClip(double magnification,
                                     java.awt.Rectangle srcRect,
                                     java.awt.Rectangle clipRect)

isOutOfRepaintingClip

public boolean isOutOfRepaintingClip(java.awt.Rectangle clipRect,
                                     double scale)
For the DisplayNavigator. No srcRect or magnification considered.


remove2

protected boolean remove2(boolean check)
Remove also from the trees if present; does nothing more than remove(boolean) unless overriden.


remove

public boolean remove(boolean check)
Remove from both the database and any Display that shows the Layer in which this Displayable is shown.

Overrides:
remove in class DBObject

link

public void link(Displayable d)
Link the given Displayable with this Displayable, and then tell the given Displayable to link this. Since the link is stored as Displayable objects in a HashSet, there'll never be repeated entries.


link

public void link(Displayable d,
                 boolean update_database)
Link the given Displayable with this Displayable, and then tell the given Displayable to link this. Since the link is stored as Displayable objects in a HashSet, there'll never be repeated entries.


unlink

public void unlink()
Remove all links held by this Displayable.


unlink

public void unlink(Displayable d)
Remove the link with the given Displayable, and tell the given Displayable to remove the link with this.


isLinked

public boolean isLinked()
Check if this object is directly linked to any other Displayable objects.


isLinked

public boolean isLinked(java.lang.Class<?> c)
Check if this object is directly linked to a Displayable object of the given Class.


isLinked

public boolean isLinked(Displayable d)
Check if thisobject is directly linked to the given Displayable.


isOnlyLinkedTo

public boolean isOnlyLinkedTo(java.lang.Class<?> c)
Check if this object is directly linked only to Displayable objects of the given class (returns true) or to none (returns true as well).


isOnlyLinkedTo

public boolean isOnlyLinkedTo(java.lang.Class<?> c,
                              Layer layer)
Check if this object is directly linked only to Displayable objects of the given class in the same layer (returns true). Returns true as well when not linked to any of the given class.


linkPatches

public boolean linkPatches()
Link the Patch objects that lay underneath the bounding box of this Displayable, so that they cannot be dragged independently.

Returns:
whether the locking state changed.

unlinkAll

public void unlinkAll(java.lang.Class<?> c)
Unlink all Displayable objects of the given type linked by this.


intersects

public boolean intersects(Displayable d)
Check if this perimeter's intersects that of the given Displayable.


intersects

public boolean intersects(java.awt.geom.Area area)

intersects

public boolean intersects(Layer layer,
                          java.awt.geom.Area area)
Calls intersects(area) unless overriden -- intended for ZDisplayable objects to return whether they intersect the given area at the given layer.


intersects

public boolean intersects(Layer layer,
                          java.awt.Rectangle r)

getIntersection

public java.awt.geom.Area getIntersection(Displayable d)
Returns the intersection of this Displayable's area with the given one.


getLinkedBox

public java.awt.Rectangle getLinkedBox(boolean same_layer)
Returns the sum of bounding boxes of all linked Displayables.


toString

public java.lang.String toString()
Minimal info that identifies this object as unique, for display on a JTree node.

Overrides:
toString in class java.lang.Object

isDeletable

public abstract boolean isDeletable()

canSendTo

public boolean canSendTo(Layer layer)
Subclasses can specify the behaviour, for the default is true.


exportSVG

public void exportSVG(java.lang.StringBuffer data,
                      double z_scale,
                      java.lang.String indent)
Does nothing unless overriden.


snapTo

public void snapTo(int cx,
                   int cy,
                   int x_p,
                   int y_p)
Does nothing unless overriden. Used for profile, pipe and ball points when preventing dragging beyond the screen, to snap to cursor when this reenters.


adjustProperties

public void adjustProperties()
Shows a dialog to adjust properties of this object.


makeAdjustPropertiesDialog

protected ij.gui.GenericDialog makeAdjustPropertiesDialog()

processAdjustPropertiesDialog

protected Displayable.DoEdit processAdjustPropertiesDialog(ij.gui.GenericDialog gd)

exportDTD

public static void exportDTD(java.lang.String type,
                             java.lang.StringBuilder sb_header,
                             java.util.HashSet<java.lang.String> hs,
                             java.lang.String indent)
Adds simply DTD !ATTRIBUTE tags. The ProjectThing that encapsulates this object will give the type.


exportDTD

public static void exportDTD(java.lang.StringBuilder sb_header,
                             java.util.HashSet<java.lang.String> hs,
                             java.lang.String indent)

commonDTDChildren

protected static java.lang.String commonDTDChildren()

exportXML

public void exportXML(java.lang.StringBuilder sb_body,
                      java.lang.String in,
                      java.lang.Object any)
The oid is this objects' id, whereas the 'id' tag will be the id of the wrapper Thing object.

Overrides:
exportXML in class DBObject

restXML

protected void restXML(java.lang.StringBuilder sb_body,
                       java.lang.String in,
                       java.lang.Object any)
Add properties, links, etc. Does NOT close the tag.


getXMLSafeValue

public static final java.lang.String getXMLSafeValue(java.util.Map.Entry<java.lang.String,java.lang.String> e,
                                                     java.lang.String value)
Make sure the value is valid for an XML attribute content inside double quotes. This means double quotes and newline characters are not allowed and are replaced by a single quote and a space, respectively.


getXMLSafeValue

public static final java.lang.String getXMLSafeValue(java.lang.String value)

hasLinkedGroupWithinLayer

public boolean hasLinkedGroupWithinLayer(Layer la)

rotatePoints

public static double[][] rotatePoints(double[][] p,
                                      double rot,
                                      double xo,
                                      double yo)
Rotate 2D points relative to the given pivot point by the given rot angle (in radians), in the 2D plane.


scalePoints

public static double[][] scalePoints(double[][] p,
                                     double sx,
                                     double sy,
                                     double xo,
                                     double yo)
Scale 2D points relative to the given pivot point xo,yo.


displacePoints

public static double[][] displacePoints(double[][] p,
                                        double dx,
                                        double dy)

transformPoint

public static void transformPoint(double[][] p,
                                  int i,
                                  double dx,
                                  double dy,
                                  double rot,
                                  double xo,
                                  double yo)
Transform in place only the 'i' point in the points array.


findNearestPoint

protected static int findNearestPoint(double[][] a,
                                      int n_points,
                                      double x_p,
                                      double y_p)
Fine nearest point in array a, from 0 up to n_points, to point x_p,y_p.

Returns:
the index of such point.

findNearestPoint

protected static int findNearestPoint(double[][] a,
                                      long[] p_layer,
                                      int n_points,
                                      double x_p,
                                      double y_p,
                                      long lid)

clone

public Displayable clone()
Performs a deep copy of this object.

Overrides:
clone in class java.lang.Object

clone

public abstract Displayable clone(Project pr,
                                  boolean copy_id)
Performs a deep copy of this object, obtaining its unique id either from the given project or the exact same as this object's id. The visibility, though, is set to true at all times.


clone

public Displayable clone(Project pr)
Performs a deep copy of this object but assigning to it the given project. The visibility, though, is set to true at all times.


getLayerSet

public LayerSet getLayerSet()

updateInDatabase

public boolean updateInDatabase(java.lang.String key)
Overrides:
updateInDatabase in class DBObject

getMinimalBoundingBox

public static java.awt.Rectangle getMinimalBoundingBox(Displayable[] d)

getAffineTransform

public java.awt.geom.AffineTransform getAffineTransform()

getAffineTransformCopy

public java.awt.geom.AffineTransform getAffineTransformCopy()

setAffineTransform

public void setAffineTransform(java.awt.geom.AffineTransform at)
Sets the matrix values of this Displayable's AffineTransform to those of the given AffineTransform.


translate

public void translate(double dx,
                      double dy,
                      boolean linked)
Translate this Displayable and its linked ones if linked=true.


translate

public void translate(double dx,
                      double dy)

rotate

public void rotate(double radians,
                   double xo,
                   double yo)
Rotate relative to an anchor point.


rotate

public void rotate(double radians,
                   double xo,
                   double yo,
                   boolean linked)
Rotate relative to an anchor point.


updateBucket

public void updateBucket()
Commands the parent container (a Layer or a LayerSet) to update the bucket position of this Displayable.


scale

public void scale(double sx,
                  double sy,
                  double xo,
                  double yo)
Scale relative to an anchor point (will translate as necessary).


scale

public void scale(double sx,
                  double sy,
                  double xo,
                  double yo,
                  boolean linked)
Scale relative to an anchor point (will translate as necessary).


setLocation

public void setLocation(double x,
                        double y)
Sets the top left of the bounding box to x,y. Warning: does not check that the object will remain within layer bounds. Does NOT affect linked Displayables.


transformPoint

public java.awt.geom.Point2D.Double transformPoint(double px,
                                                   double py)
Apply this Displayable's AffineTransform to the given point.


inverseTransformPoint

public java.awt.geom.Point2D.Double inverseTransformPoint(double px,
                                                          double py)

transformRectangle

public final java.awt.Rectangle transformRectangle(java.awt.Rectangle r)
Returns a new Rectangle which encloses completly the given rectangle after transforming it with this Displayable's AffineTransform. The given rectangle's fields are untouched.


transformPoints

public double[][] transformPoints(double[][] p)
Returns the argument if this Displayable's AffineTransform is the identity; otherwise returns a new double[][] with all points from @param p transformed according to the AffineTransform. The double[][] array provided as argument is expected to be of type [2][length], i.e. two arrays describing x and y, and it is left intact.


transformPoints

protected double[][] transformPoints(double[][] p,
                                     int length)

transformPoints

public double[][] transformPoints(double[][] p,
                                  java.awt.geom.AffineTransform additional)

transformPoints

protected final double[][] transformPoints(double[][] p,
                                           int length,
                                           java.awt.geom.AffineTransform additional)
Will crop second dimension of the given array at the given length.


transformPoints

protected static final double[][] transformPoints(java.awt.geom.AffineTransform aff,
                                                  double[][] p,
                                                  int length)
Will crop second dimension of the given array at the given length.


transformPoints

protected double[] transformPoints(double[] p,
                                   java.awt.geom.AffineTransform additional)

transformPoints

protected static double[] transformPoints(java.awt.geom.AffineTransform aff,
                                          double[] p)

transformPoints

protected double[] transformPoints(double[] p)
Transforms the points represented as X1,Y1,X2,Y2...


transformPoints

protected float[] transformPoints(float[] p)
Transforms the points represented as X1,Y1,X2,Y2...


transform

public void transform(java.awt.geom.AffineTransform at)
Concatenate the given affine to this and all its linked objects.


preTransform

public void preTransform(java.awt.geom.AffineTransform affine,
                         boolean linked)
preConcatenate the given affine transform to this Displayable's affine.


paintAsBox

public void paintAsBox(java.awt.Graphics2D g)

paintSnapshot

public void paintSnapshot(java.awt.Graphics2D g,
                          Layer layer,
                          java.util.List<Layer> layers,
                          java.awt.Rectangle srcRect,
                          double mag)

findById

public DBObject findById(long id)

measure

public ij.measure.ResultsTable measure(ij.measure.ResultsTable rt)
Does nothing unless overriden.


getBucketable

public Bucketable getBucketable()

getNameId

protected double getNameId()
If the title is purely numeric, returns it as a double; otherwise returns 0.


areThereLayerCrossLinks

public static final boolean areThereLayerCrossLinks(java.util.Set<Layer> sublist,
                                                    boolean ignore_stacks)
Returns true if any Displayable objects of different layers in sublist are linked to each other. If ignore_stacks is true, then image links across layers are ignored.


getLayerIds

public java.util.Collection<java.lang.Long> getLayerIds()

getLayersWithData

public java.util.Collection<Layer> getLayersWithData()
Override it to provide Layer pointers directly.


getArea

public java.awt.geom.Area getArea()

getAreaAt

public java.awt.geom.Area getAreaAt(Layer layer)
This area is meant to represent the entire area where a Displayable paints to in the @param layer. But for some this is reduced to areas with data, not with interpolated data. For example, a Polyine would show a list of little 1x1 rectangles for each point in the @param layer.


getAreaForBucket

protected java.awt.geom.Area getAreaForBucket(Layer layer)
Should call getAreaAt(layer), or methods that are similar but faster.


isRoughlyInside

protected boolean isRoughlyInside(Layer layer,
                                  java.awt.Rectangle r)
If this Displayable intersects with @param r or almost intersects, then returns true. This method is meant to be very fast, and err on the "yes" and never on the "no".


setAnnotation

public void setAnnotation(java.lang.String annotation)

getAnnotation

public java.lang.String getAnnotation()
Returns null if none.


softRemove

public boolean softRemove()
Calls remove(false) unless overriden.


deselect

public void deselect()
Tell this Displayable that is has been deselected from a Display. If multiple displays have the same Displayable in their Selection, this Diplayabale is to act as if it has been deselected from all.