|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavamorph.CPolygonDecorator
public class CPolygonDecorator
Field Summary | |
---|---|
private double[][] |
clip
Smoothed clip polygon matrix. |
static Color |
CURSOR_COLOR
Color of the polygon point move cursor. |
private File |
f_clip
File to save a debug copy of the clip matrix to. |
private File |
f_poly
File to save the polygon to after shutdown. |
private BufferedImage |
image
Picture of the own side. |
private int |
index
Index of the current polygon point which has the cursor. |
private CFrame |
parent
Parent component to draw the polygon to. |
private Vector<Point> |
polygon
Collection of the polygon's points. |
static Color |
POLYGON_COLOR
Color of the polygon lines. |
private Point |
pos
Fine position of the mouse pointer in picture pixels. |
Constructor Summary | |
---|---|
CPolygonDecorator(CFrame parent,
Vector<Point> polygon,
BufferedImage image,
File f_poly,
double[][] clip,
File f_clip)
Constructor. |
Method Summary | |
---|---|
void |
clip()
Ensures that the cursor points to a valid polygon point. |
private void |
drawLine(Point p1,
Point p2)
Draw a line between two polygon points into the clip matrix. |
private void |
fill()
Fill the inner of the polygon with ratio 1.0. |
void |
genClip()
Provide the clip matrix. |
private int |
getIndex(Point p)
Seek the index of that one mesh point which is nearest to the mouse cursor. |
void |
init()
Create a default polygon, depending on configuration coordinates, when initialization by file isn't possible of isn't intended. |
void |
load()
Load the polygon from file. |
void |
mouseClicked(MouseEvent e)
Due to Java API. |
void |
mouseDragged(MouseEvent e)
The user is moving a polygon point. |
void |
mouseEntered(MouseEvent e)
Due to Java API. |
void |
mouseExited(MouseEvent e)
Due to Java API. |
void |
mouseMoved(MouseEvent e)
Detect the current edit able polygon point before & during moving. |
void |
mousePressed(MouseEvent e)
Due to Java API. |
void |
mouseReleased(MouseEvent e)
Due to Java API. |
void |
paint(Graphics g)
Draw the polygon to the parent JComponent. |
void |
run()
Save-on-shutdown-thread. |
private void |
smoothCircle(Point p)
Perform actually smooth for one pixel |
private void |
smoothLine(Point p1,
Point p2)
Smooth the contour of the clip matrix as dilatation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Color POLYGON_COLOR
public static final Color CURSOR_COLOR
private CFrame parent
private int index
private Vector<Point> polygon
private BufferedImage image
private double[][] clip
private File f_poly
private File f_clip
private Point pos
Constructor Detail |
---|
public CPolygonDecorator(CFrame parent, Vector<Point> polygon, BufferedImage image, File f_poly, double[][] clip, File f_clip)
parent
- Parent JComponent to paint to.polygon
- Points of the clip polygon.image
- Picture of the own side.f_poly
- File to save the polygon to after shutdown.clip
- Smoothed clip matrix.f_clip
- File to store a debug copy of the to.Method Detail |
---|
public void clip()
public void paint(Graphics g)
paint
in interface IDecorator
g
- Graphics context of the JComponent.public void mouseDragged(MouseEvent e)
mouseDragged
in interface MouseMotionListener
public void mouseMoved(MouseEvent e)
mouseMoved
in interface MouseMotionListener
public void genClip()
public void run()
run
in interface Runnable
public void load()
public void init()
private void fill()
private void drawLine(Point p1, Point p2)
p1
- First point.p2
- Second point.
|x| |x1| |x2 - x1| 0.0 <= p <= 1.0
| | = | | + p * | | resolution depends on longer
|y| |y1| |y2 - y1| orthogonal difference.
Line is orthogonal pixel proof.private void smoothLine(Point p1, Point p2)
p1
- First point.p2
- Second point.private void smoothCircle(Point p)
p
- The current pixel.public void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
private int getIndex(Point p)
p
- on screen, scaled to picture coordinates.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |