fr.inria.zvtm.glyphs
Class FPolygon

java.lang.Object
  extended by fr.inria.zvtm.glyphs.Glyph
      extended by fr.inria.zvtm.glyphs.ClosedShape
          extended by fr.inria.zvtm.glyphs.FPolygon
All Implemented Interfaces:
Translucent, Cloneable

public class FPolygon
extends ClosedShape

Fast Polygon. Can neither be resized nor reoriented (for now). This is the old implementation of VPolygon, as found in ZVTM 0.8.2.
The new version of VPolygon can be resized, but at some cost from an efficiency point of view, so the old version is still provided here and can be used by people who do not intend to resize their Polygon instances.
This implementation uses doubles instead of doubles for its internal representation of the vertices, see VPolygon for more details.

Author:
Emmanuel Pietriga
See Also:
VPolygon

Field Summary
 
Fields inherited from class fr.inria.zvtm.glyphs.ClosedShape
bColor, borderColor, cursorInsideFColor, HSVb
 
Fields inherited from class fr.inria.zvtm.glyphs.Glyph
alphaC, coef, color, cursorInsideColor, ENTERED_GLYPH, EXITED_GLYPH, fColor, HSV, NO_CURSOR_EVENT, orient, sensit, size, stickedTo, stroke, visible, vx, vy, vz
 
Fields inherited from interface fr.inria.zvtm.glyphs.Translucent
acO
 
Constructor Summary
FPolygon(Point2D.Double[] v, int z, Color c)
           
FPolygon(Point2D.Double[] v, int z, Color c, Color bc)
           
FPolygon(Point2D.Double[] v, int z, Color c, Color bc, float alpha)
           
 
Method Summary
 void addCamera(int verifIndex)
          Create new projected coordinates.
 Object clone()
           
 boolean coordInside(int jpx, int jpy, int camIndex, double cvx, double cvy)
          Detect whether the given point is inside this glyph or not.
 void draw(Graphics2D g, int vW, int vH, int i, Stroke stdS, AffineTransform stdT, int dx, int dy)
          Draw this glyph.
 void drawForLens(Graphics2D g, int vW, int vH, int i, Stroke stdS, AffineTransform stdT, int dx, int dy)
          Draw this glyph through a lens.
 boolean fillsView(double w, double h, int camIndex)
          Find out if this glyph completely fills a view.
 Point2D.Double[] getAbsoluteVertices()
          Get this polygon's list of vertices (absolute coordinates).
 double getArea()
          Get the polygon's area.
 Point2D.Double getCentroid()
          Get the double precision coordinates of this polygon's centroid.
 Shape getJava2DShape()
          Get the Java2D Shape corresponding to this Glyph.
 double getOrient()
          Get the glyph's orientation.
 double getSize()
          Get glyph's size (diameter of bounding circle).
 Point2D.Double[] getVertices()
          Get this polygon's list of vertices (relative coordinates).
 String getVerticesAsText()
          Get a serialization of this polygon's list of vertices.
 void initCams(int nbCam)
          Initialize projected coordinates.
 short mouseInOut(int jpx, int jpy, int camIndex, double cvx, double cvy)
          Method used internally for firing picking-related events.
 void orientTo(double angle)
          Cannot be reoriented.
 void project(Camera c, Dimension d)
          Project glyph w.r.t a given camera's coordinate system, prior to actual painting.
 void projectForLens(Camera c, int lensWidth, int lensHeight, float lensMag, double lensx, double lensy)
          Project glyph w.r.t a given camera's coordinate system, prior to actual painting through a lens.
 void removeCamera(int index)
          Dispose of projected coordinates.
 void resetMouseIn()
          Reset memory of cursor being inside the glyph.
 void resetMouseIn(int i)
          Reset memory of cursor being inside the glyph for projected coordinates associated with camera at index i.
 void reSize(double factor)
          Cannot be resized.
 void sizeTo(double radius)
          Cannot be resized.
 boolean visibleInDisc(double dvx, double dvy, double dvr, Shape dvs, int camIndex, int jpx, int jpy, int dpr)
          The disc is actually approximated to its bounding box here.
 
Methods inherited from class fr.inria.zvtm.glyphs.ClosedShape
addHSVbColor, getBorderColor, getDefaultBorderColor, getHSVbColor, highlight, isBorderDrawn, isFilled, setBorderColor, setCursorInsideFillColor, setDrawBorder, setFilled, setHSVbColor
 
Methods inherited from class fr.inria.zvtm.glyphs.Glyph
addHSVColor, containedInRegion, getBounds, getColor, getDefaultColor, getDefaultCursorInsideHighlightColor, getHSVColor, getLocation, getOwner, getStickedGlyphArray, getStroke, getTranslucencyValue, getType, getZindex, isSelected, isSensitive, isVisible, isVisibleThroughLens, move, moveTo, propagateMove, select, setColor, setCursorInsideHighlightColor, setDefaultCursorInsideHighlightColor, setHSVColor, setOwner, setSensitivity, setStroke, setTranslucencyValue, setType, setVisible, setZindex, stick, stickToGlyph, toString, unstick, unstickAllGlyphs, unstickAllGlyphs, unstickFromGlyph, visibleInRegion, visibleInViewport
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FPolygon

public FPolygon(Point2D.Double[] v,
                int z,
                Color c)
Parameters:
v - list of x,y vertices ABSOLUTE coordinates
c - fill color

FPolygon

public FPolygon(Point2D.Double[] v,
                int z,
                Color c,
                Color bc)

FPolygon

public FPolygon(Point2D.Double[] v,
                int z,
                Color c,
                Color bc,
                float alpha)
Parameters:
v - list of x,y vertices ABSOLUTE coordinates
c - fill color
bc - border color
alpha - in [0;1.0]. 0 is fully transparent, 1 is opaque
Method Detail

initCams

public void initCams(int nbCam)
Description copied from class: Glyph
Initialize projected coordinates. Called internally when glyph is created in order to create the initial set of projected coordinates w.r.t the number of cameras in the virtual space.

Specified by:
initCams in class Glyph
Parameters:
nbCam - current number of cameras in the virtual space
See Also:
Glyph.addCamera(int verifIndex), Glyph.removeCamera(int index)

addCamera

public void addCamera(int verifIndex)
Description copied from class: Glyph
Create new projected coordinates. Called internally to create new projected coordinates to use with the new camera.

Specified by:
addCamera in class Glyph
Parameters:
verifIndex - camera index, just to be sure that the number of projected coordinates is consistent with the number of cameras.
See Also:
Glyph.initCams(int nbCam), Glyph.removeCamera(int index)

removeCamera

public void removeCamera(int index)
Description copied from class: Glyph
Dispose of projected coordinates. If a camera is removed from the virtual space to which this glyphs belongs, the corresponding projected coordinates should be deleted. the array of projected coordinates should not be modified however, because other cameras' index remain the same. The corresponding index in the array should just be set to null.

Specified by:
removeCamera in class Glyph
See Also:
Glyph.initCams(int nbCam), Glyph.addCamera(int verifIndex)

resetMouseIn

public void resetMouseIn()
Description copied from class: Glyph
Reset memory of cursor being inside the glyph.

Specified by:
resetMouseIn in class Glyph

resetMouseIn

public void resetMouseIn(int i)
Description copied from class: Glyph
Reset memory of cursor being inside the glyph for projected coordinates associated with camera at index i.

Specified by:
resetMouseIn in class Glyph

getOrient

public double getOrient()
Description copied from class: Glyph
Get the glyph's orientation.

Specified by:
getOrient in class Glyph

orientTo

public void orientTo(double angle)
Cannot be reoriented.

Specified by:
orientTo in class Glyph
Parameters:
angle - in [0:2Pi[

getSize

public double getSize()
Description copied from class: Glyph
Get glyph's size (diameter of bounding circle).

Specified by:
getSize in class Glyph

sizeTo

public void sizeTo(double radius)
Cannot be resized.

Specified by:
sizeTo in class Glyph
See Also:
Glyph.reSize(double factor)

reSize

public void reSize(double factor)
Cannot be resized.

Specified by:
reSize in class Glyph
See Also:
Glyph.sizeTo(double s)

fillsView

public boolean fillsView(double w,
                         double h,
                         int camIndex)
Description copied from class: Glyph
Find out if this glyph completely fills a view. (In which case it is not necessary to repaint objects below it in the drawing stack). If implemented, this method should be very efficient, as it is used by an optional top-down clipping algorithm. Otherwise it might cost more time than it can potentially save. Until now it has only been implemented for non-reorientable rectangles and was activated only for treemap-like representations in which a lot of rectangles can potentially overlap each other.

Specified by:
fillsView in class Glyph

coordInside

public boolean coordInside(int jpx,
                           int jpy,
                           int camIndex,
                           double cvx,
                           double cvy)
Description copied from class: Glyph
Detect whether the given point is inside this glyph or not.

Specified by:
coordInside in class Glyph
Parameters:
jpx - provide projected JPanel coordinates of the associated view, not virtual space coordinates
jpy - provide projected JPanel coordinates of the associated view, not virtual space coordinates
cvx - virtual space coordinates
cvy - virtual space coordinates

visibleInDisc

public boolean visibleInDisc(double dvx,
                             double dvy,
                             double dvr,
                             Shape dvs,
                             int camIndex,
                             int jpx,
                             int jpy,
                             int dpr)
The disc is actually approximated to its bounding box here. Precise intersection computation would be too costly.

Overrides:
visibleInDisc in class Glyph

mouseInOut

public short mouseInOut(int jpx,
                        int jpy,
                        int camIndex,
                        double cvx,
                        double cvy)
Description copied from class: Glyph
Method used internally for firing picking-related events.

Specified by:
mouseInOut in class Glyph
Parameters:
jpx - provide projected JPanel coordinates of the associated view, not virtual space coordinates
jpy - provide projected JPanel coordinates of the associated view, not virtual space coordinates
cvx - virtual space coordinates
cvy - virtual space coordinates
Returns:
VCursor.ENTERED_GLYPH if cursor has entered the glyph, VCursor.EXITED_GLYPH if it has exited the glyph, VCursor.NO_CURSOR_EVENT if nothing has changed (meaning the cursor was already inside or outside it)

getVertices

public Point2D.Double[] getVertices()
Get this polygon's list of vertices (relative coordinates).

Returns:
relative coordinates (w.r.t polygon's centroid)

getAbsoluteVertices

public Point2D.Double[] getAbsoluteVertices()
Get this polygon's list of vertices (absolute coordinates).

Returns:
absolute coordinates

getVerticesAsText

public String getVerticesAsText()
Get a serialization of this polygon's list of vertices.

Returns:
a semicolon-separated string representation of all vertex absolute coordinates (x and y coordinates seperated by commas, e.g. x1,y1;x2,y2;x3,y3 etc.)

project

public void project(Camera c,
                    Dimension d)
Description copied from class: Glyph
Project glyph w.r.t a given camera's coordinate system, prior to actual painting. Called internally.

Specified by:
project in class Glyph
Parameters:
c - camera
d - dimension of View using camera c

projectForLens

public void projectForLens(Camera c,
                           int lensWidth,
                           int lensHeight,
                           float lensMag,
                           double lensx,
                           double lensy)
Description copied from class: Glyph
Project glyph w.r.t a given camera's coordinate system, prior to actual painting through a lens. Called internally.

Specified by:
projectForLens in class Glyph
Parameters:
c - camera
lensWidth - width of lens activated in View using this camera
lensHeight - height of lens activated in View using this camera
lensMag - magnification factor of lens activated in View using this camera
lensx - horizontal coordinateof lens activated in View using this camera
lensy - vertical coordinate of lens activated in View using this camera

draw

public void draw(Graphics2D g,
                 int vW,
                 int vH,
                 int i,
                 Stroke stdS,
                 AffineTransform stdT,
                 int dx,
                 int dy)
Description copied from class: Glyph
Draw this glyph.

Specified by:
draw in class Glyph
Parameters:
g - graphics context in which the glyph should be drawn
vW - associated View width (used by some closed shapes to determine if it is worth painting the glyph's border)
vH - associated View height (used by some closed shapes to determine if it is worth painting the glyph's border)
i - camera index in the virtual space containing the glyph
stdS - default stroke
stdT - identity transform
dx - horizontal offset
dy - vertical offset

drawForLens

public void drawForLens(Graphics2D g,
                        int vW,
                        int vH,
                        int i,
                        Stroke stdS,
                        AffineTransform stdT,
                        int dx,
                        int dy)
Description copied from class: Glyph
Draw this glyph through a lens.

Specified by:
drawForLens in class Glyph
Parameters:
g - graphics context in which the glyph should be drawn
vW - associated View width (used by some closed shapes to determine if it is worth painting the glyph's border)
vH - associated View height (used by some closed shapes to determine if it is worth painting the glyph's border)
i - camera index in the virtual space containing the glyph
stdS - default stroke
stdT - identity transform
dx - horizontal offset
dy - vertical offset

getArea

public double getArea()
Get the polygon's area.


getCentroid

public Point2D.Double getCentroid()
Get the double precision coordinates of this polygon's centroid.

See Also:
getCentroid()

getJava2DShape

public Shape getJava2DShape()
Get the Java2D Shape corresponding to this Glyph. Virtual Space coordinates. Warning: the polygon's coordinates are converted to 32-bit integers for now (we use a java.awt.Polygon)

Specified by:
getJava2DShape in class Glyph

clone

public Object clone()
Overrides:
clone in class Glyph


Copyright © 2000-2002 Xerox Corporation. All Rights Reserved
Copyright © 2003 World Wide Web Consortium. All Rights Reserved
Copyright © 2004-2011 INRIA. All Rights Reserved
Licensed under the GNU LGPL. For full terms see the file COPYING.