mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
auto-gc
This commit is contained in:
Binary file not shown.
+3
@@ -126,6 +126,9 @@ public class ResistorInstance implements IComponentInstance {
|
|||||||
public void draw(Graphics2D g2d, ComponentState componentState) {
|
public void draw(Graphics2D g2d, ComponentState componentState) {
|
||||||
g2d.setColor(componentState.equals(ComponentState.SELECTED) ? color : color.darker());
|
g2d.setColor(componentState.equals(ComponentState.SELECTED) ? color : color.darker());
|
||||||
g2d.setStroke(new BasicStroke(2));
|
g2d.setStroke(new BasicStroke(2));
|
||||||
|
if (componentState == ComponentState.DRAGGING) {
|
||||||
|
g2d.setStroke(new BasicStroke(1));
|
||||||
|
}
|
||||||
g2d.drawLine(leftTopCorner.x, leftTopCorner.y, otherCorner.x, otherCorner.y);
|
g2d.drawLine(leftTopCorner.x, leftTopCorner.y, otherCorner.x, otherCorner.y);
|
||||||
g2d.fillRect((leftTopCorner.x + otherCorner.x) / 2 - 10,
|
g2d.fillRect((leftTopCorner.x + otherCorner.x) / 2 - 10,
|
||||||
(leftTopCorner.y + otherCorner.y) / 2 - 10, 20, 20);
|
(leftTopCorner.y + otherCorner.y) / 2 - 10, 20, 20);
|
||||||
|
|||||||
+1
-1
@@ -7,5 +7,5 @@ package com.diyfever.diylc.model;
|
|||||||
*/
|
*/
|
||||||
public enum ComponentState {
|
public enum ComponentState {
|
||||||
|
|
||||||
NORMAL, SELECTED, LOCKED
|
NORMAL, SELECTED, LOCKED, DRAGGING
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -78,7 +78,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
|
|
||||||
private MemoryBar getMemoryPanel() {
|
private MemoryBar getMemoryPanel() {
|
||||||
if (memoryPanel == null) {
|
if (memoryPanel == null) {
|
||||||
memoryPanel = new MemoryBar();
|
memoryPanel = new MemoryBar(true);
|
||||||
}
|
}
|
||||||
return memoryPanel;
|
return memoryPanel;
|
||||||
}
|
}
|
||||||
|
|||||||
-210
@@ -85,399 +85,258 @@ class G2DWrapper extends Graphics2D {
|
|||||||
currentArea.add(new Area(s));
|
currentArea.add(new Area(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void addRenderingHints(Map<?, ?> hints) {
|
public void addRenderingHints(Map<?, ?> hints) {
|
||||||
canvasGraphics.addRenderingHints(hints);
|
canvasGraphics.addRenderingHints(hints);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void clip(Shape s) {
|
public void clip(Shape s) {
|
||||||
canvasGraphics.clip(s);
|
canvasGraphics.clip(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Shape s) {
|
public void draw(Shape s) {
|
||||||
canvasGraphics.draw(s);
|
canvasGraphics.draw(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void drawGlyphVector(GlyphVector g, float x, float y) {
|
public void drawGlyphVector(GlyphVector g, float x, float y) {
|
||||||
canvasGraphics.drawGlyphVector(g, x, y);
|
canvasGraphics.drawGlyphVector(g, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) {
|
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) {
|
||||||
// FIXME: process map
|
// FIXME: process map
|
||||||
return canvasGraphics.drawImage(img, xform, obs);
|
return canvasGraphics.drawImage(img, xform, obs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) {
|
public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) {
|
||||||
canvasGraphics.drawImage(img, op, x, y);
|
canvasGraphics.drawImage(img, op, x, y);
|
||||||
// FIXME: process map
|
// FIXME: process map
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
|
public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
|
||||||
canvasGraphics.drawRenderableImage(img, xform);
|
canvasGraphics.drawRenderableImage(img, xform);
|
||||||
// FIXME: process map
|
// FIXME: process map
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
|
public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
|
||||||
canvasGraphics.drawRenderedImage(img, xform);
|
canvasGraphics.drawRenderedImage(img, xform);
|
||||||
// FIXME: process map
|
// FIXME: process map
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void drawString(String str, int x, int y) {
|
public void drawString(String str, int x, int y) {
|
||||||
canvasGraphics.drawString(str, x, y);
|
canvasGraphics.drawString(str, x, y);
|
||||||
// FIXME: process map
|
// FIXME: process map
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void drawString(String str, float x, float y) {
|
public void drawString(String str, float x, float y) {
|
||||||
canvasGraphics.drawString(str, x, y);
|
canvasGraphics.drawString(str, x, y);
|
||||||
// FIXME: process map
|
// FIXME: process map
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void drawString(AttributedCharacterIterator iterator, int x, int y) {
|
public void drawString(AttributedCharacterIterator iterator, int x, int y) {
|
||||||
canvasGraphics.drawString(iterator, x, y);
|
canvasGraphics.drawString(iterator, x, y);
|
||||||
// FIXME: process map
|
// FIXME: process map
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void drawString(AttributedCharacterIterator iterator, float x, float y) {
|
public void drawString(AttributedCharacterIterator iterator, float x, float y) {
|
||||||
canvasGraphics.drawString(iterator, x, y);
|
canvasGraphics.drawString(iterator, x, y);
|
||||||
// FIXME: process map
|
// FIXME: process map
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void fill(Shape s) {
|
public void fill(Shape s) {
|
||||||
canvasGraphics.fill(s);
|
canvasGraphics.fill(s);
|
||||||
appendShape(s);
|
appendShape(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public Color getBackground() {
|
public Color getBackground() {
|
||||||
return canvasGraphics.getBackground();
|
return canvasGraphics.getBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public Composite getComposite() {
|
public Composite getComposite() {
|
||||||
return canvasGraphics.getComposite();
|
return canvasGraphics.getComposite();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public GraphicsConfiguration getDeviceConfiguration() {
|
public GraphicsConfiguration getDeviceConfiguration() {
|
||||||
return canvasGraphics.getDeviceConfiguration();
|
return canvasGraphics.getDeviceConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public FontRenderContext getFontRenderContext() {
|
public FontRenderContext getFontRenderContext() {
|
||||||
return canvasGraphics.getFontRenderContext();
|
return canvasGraphics.getFontRenderContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public Paint getPaint() {
|
public Paint getPaint() {
|
||||||
return canvasGraphics.getPaint();
|
return canvasGraphics.getPaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public Object getRenderingHint(Key hintKey) {
|
public Object getRenderingHint(Key hintKey) {
|
||||||
return canvasGraphics.getRenderingHint(hintKey);
|
return canvasGraphics.getRenderingHint(hintKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public RenderingHints getRenderingHints() {
|
public RenderingHints getRenderingHints() {
|
||||||
return canvasGraphics.getRenderingHints();
|
return canvasGraphics.getRenderingHints();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public Stroke getStroke() {
|
public Stroke getStroke() {
|
||||||
return canvasGraphics.getStroke();
|
return canvasGraphics.getStroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public AffineTransform getTransform() {
|
public AffineTransform getTransform() {
|
||||||
return canvasGraphics.getTransform();
|
return canvasGraphics.getTransform();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
|
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
|
||||||
return canvasGraphics.hit(rect, s, onStroke);
|
return canvasGraphics.hit(rect, s, onStroke);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void rotate(double theta) {
|
public void rotate(double theta) {
|
||||||
canvasGraphics.rotate(theta);
|
canvasGraphics.rotate(theta);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void rotate(double theta, double x, double y) {
|
public void rotate(double theta, double x, double y) {
|
||||||
canvasGraphics.rotate(theta, x, y);
|
canvasGraphics.rotate(theta, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void scale(double sx, double sy) {
|
public void scale(double sx, double sy) {
|
||||||
canvasGraphics.scale(sx, sy);
|
canvasGraphics.scale(sx, sy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void setBackground(Color color) {
|
public void setBackground(Color color) {
|
||||||
canvasGraphics.setBackground(color);
|
canvasGraphics.setBackground(color);
|
||||||
// FIXME: fix map
|
// FIXME: fix map
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void setComposite(Composite comp) {
|
public void setComposite(Composite comp) {
|
||||||
canvasGraphics.setComposite(comp);
|
canvasGraphics.setComposite(comp);
|
||||||
// FIXME: check this.
|
// FIXME: check this.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void setPaint(Paint paint) {
|
public void setPaint(Paint paint) {
|
||||||
canvasGraphics.setPaint(paint);
|
canvasGraphics.setPaint(paint);
|
||||||
// FIXME: check this
|
// FIXME: check this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void setRenderingHint(Key hintKey, Object hintValue) {
|
public void setRenderingHint(Key hintKey, Object hintValue) {
|
||||||
canvasGraphics.setRenderingHint(hintKey, hintValue);
|
canvasGraphics.setRenderingHint(hintKey, hintValue);
|
||||||
// FIXME: check this
|
// FIXME: check this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void setRenderingHints(Map<?, ?> hints) {
|
public void setRenderingHints(Map<?, ?> hints) {
|
||||||
canvasGraphics.setRenderingHints(hints);
|
canvasGraphics.setRenderingHints(hints);
|
||||||
// FIXME: check this
|
// FIXME: check this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void setStroke(Stroke s) {
|
public void setStroke(Stroke s) {
|
||||||
canvasGraphics.setStroke(s);
|
canvasGraphics.setStroke(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void setTransform(AffineTransform Tx) {
|
public void setTransform(AffineTransform Tx) {
|
||||||
canvasGraphics.setTransform(Tx);
|
canvasGraphics.setTransform(Tx);
|
||||||
currentTx = Tx;
|
currentTx = Tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void shear(double shx, double shy) {
|
public void shear(double shx, double shy) {
|
||||||
canvasGraphics.shear(shx, shy);
|
canvasGraphics.shear(shx, shy);
|
||||||
currentTx.shear(shx, shy);
|
currentTx.shear(shx, shy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void transform(AffineTransform Tx) {
|
public void transform(AffineTransform Tx) {
|
||||||
canvasGraphics.transform(Tx);
|
canvasGraphics.transform(Tx);
|
||||||
currentTx.concatenate(Tx);
|
currentTx.concatenate(Tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(int x, int y) {
|
public void translate(int x, int y) {
|
||||||
canvasGraphics.translate(x, y);
|
canvasGraphics.translate(x, y);
|
||||||
currentTx.translate(x, y);
|
currentTx.translate(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(double tx, double ty) {
|
public void translate(double tx, double ty) {
|
||||||
canvasGraphics.translate(tx, ty);
|
canvasGraphics.translate(tx, ty);
|
||||||
currentTx.translate(tx, ty);
|
currentTx.translate(tx, ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void clearRect(int x, int y, int width, int height) {
|
public void clearRect(int x, int y, int width, int height) {
|
||||||
canvasGraphics.clearRect(x, y, width, height);
|
canvasGraphics.clearRect(x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void clipRect(int x, int y, int width, int height) {
|
public void clipRect(int x, int y, int width, int height) {
|
||||||
canvasGraphics.clipRect(x, y, width, height);
|
canvasGraphics.clipRect(x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void copyArea(int x, int y, int width, int height, int dx, int dy) {
|
public void copyArea(int x, int y, int width, int height, int dx, int dy) {
|
||||||
canvasGraphics.copyArea(x, y, width, height, dx, dy);
|
canvasGraphics.copyArea(x, y, width, height, dx, dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public Graphics create() {
|
public Graphics create() {
|
||||||
return canvasGraphics.create();
|
return canvasGraphics.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
canvasGraphics.dispose();
|
canvasGraphics.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
|
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
|
||||||
canvasGraphics.drawArc(x, y, width, height, startAngle, arcAngle);
|
canvasGraphics.drawArc(x, y, width, height, startAngle, arcAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
|
public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
|
||||||
// FIXME: map
|
// FIXME: map
|
||||||
return canvasGraphics.drawImage(img, x, y, observer);
|
return canvasGraphics.drawImage(img, x, y, observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) {
|
public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) {
|
||||||
// FIXME: map
|
// FIXME: map
|
||||||
return canvasGraphics.drawImage(img, x, y, bgcolor, observer);
|
return canvasGraphics.drawImage(img, x, y, bgcolor, observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) {
|
public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) {
|
||||||
// FIXME: map
|
// FIXME: map
|
||||||
return canvasGraphics.drawImage(img, x, y, width, height, observer);
|
return canvasGraphics.drawImage(img, x, y, width, height, observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor,
|
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor,
|
||||||
ImageObserver observer) {
|
ImageObserver observer) {
|
||||||
@@ -485,9 +344,6 @@ class G2DWrapper extends Graphics2D {
|
|||||||
return canvasGraphics.drawImage(img, x, y, width, height, bgcolor, observer);
|
return canvasGraphics.drawImage(img, x, y, width, height, bgcolor, observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
|
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
|
||||||
int sx2, int sy2, ImageObserver observer) {
|
int sx2, int sy2, ImageObserver observer) {
|
||||||
@@ -495,9 +351,6 @@ class G2DWrapper extends Graphics2D {
|
|||||||
return canvasGraphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer);
|
return canvasGraphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
|
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1,
|
||||||
int sx2, int sy2, Color bgcolor, ImageObserver observer) {
|
int sx2, int sy2, Color bgcolor, ImageObserver observer) {
|
||||||
@@ -505,174 +358,111 @@ class G2DWrapper extends Graphics2D {
|
|||||||
return drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer);
|
return drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void drawLine(int x1, int y1, int x2, int y2) {
|
public void drawLine(int x1, int y1, int x2, int y2) {
|
||||||
canvasGraphics.drawLine(x1, y1, x2, y2);
|
canvasGraphics.drawLine(x1, y1, x2, y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void drawOval(int x, int y, int width, int height) {
|
public void drawOval(int x, int y, int width, int height) {
|
||||||
canvasGraphics.drawOval(x, y, width, height);
|
canvasGraphics.drawOval(x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void drawPolygon(int[] points, int[] points2, int points3) {
|
public void drawPolygon(int[] points, int[] points2, int points3) {
|
||||||
canvasGraphics.drawPolygon(points, points2, points3);
|
canvasGraphics.drawPolygon(points, points2, points3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void drawPolyline(int[] points, int[] points2, int points3) {
|
public void drawPolyline(int[] points, int[] points2, int points3) {
|
||||||
canvasGraphics.drawPolyline(points, points2, points3);
|
canvasGraphics.drawPolyline(points, points2, points3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
|
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
|
||||||
canvasGraphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
|
canvasGraphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
|
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
|
||||||
canvasGraphics.fillArc(x, y, width, height, startAngle, arcAngle);
|
canvasGraphics.fillArc(x, y, width, height, startAngle, arcAngle);
|
||||||
appendShape(new Arc2D.Double(x, y, width, height, startAngle, arcAngle, Arc2D.PIE));
|
appendShape(new Arc2D.Double(x, y, width, height, startAngle, arcAngle, Arc2D.PIE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void fillOval(int x, int y, int width, int height) {
|
public void fillOval(int x, int y, int width, int height) {
|
||||||
canvasGraphics.fillOval(x, y, width, height);
|
canvasGraphics.fillOval(x, y, width, height);
|
||||||
appendShape(new Ellipse2D.Double(x, y, width, height));
|
appendShape(new Ellipse2D.Double(x, y, width, height));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void fillPolygon(int[] points, int[] points2, int points3) {
|
public void fillPolygon(int[] points, int[] points2, int points3) {
|
||||||
canvasGraphics.fillPolygon(points, points2, points3);
|
canvasGraphics.fillPolygon(points, points2, points3);
|
||||||
appendShape(new Polygon(points, points2, points3));
|
appendShape(new Polygon(points, points2, points3));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void fillRect(int x, int y, int width, int height) {
|
public void fillRect(int x, int y, int width, int height) {
|
||||||
canvasGraphics.fillRect(x, y, width, height);
|
canvasGraphics.fillRect(x, y, width, height);
|
||||||
appendShape(new Rectangle(x, y, width, height));
|
appendShape(new Rectangle(x, y, width, height));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
|
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
|
||||||
canvasGraphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
|
canvasGraphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
|
||||||
appendShape(new RoundRectangle2D.Double(x, y, width, height, arcWidth, arcHeight));
|
appendShape(new RoundRectangle2D.Double(x, y, width, height, arcWidth, arcHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public Shape getClip() {
|
public Shape getClip() {
|
||||||
return canvasGraphics.getClip();
|
return canvasGraphics.getClip();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public Rectangle getClipBounds() {
|
public Rectangle getClipBounds() {
|
||||||
return canvasGraphics.getClipBounds();
|
return canvasGraphics.getClipBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public Color getColor() {
|
public Color getColor() {
|
||||||
return canvasGraphics.getColor();
|
return canvasGraphics.getColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public Font getFont() {
|
public Font getFont() {
|
||||||
return canvasGraphics.getFont();
|
return canvasGraphics.getFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public FontMetrics getFontMetrics(Font f) {
|
public FontMetrics getFontMetrics(Font f) {
|
||||||
return canvasGraphics.getFontMetrics(f);
|
return canvasGraphics.getFontMetrics(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void setClip(Shape clip) {
|
public void setClip(Shape clip) {
|
||||||
canvasGraphics.setClip(clip);
|
canvasGraphics.setClip(clip);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void setClip(int x, int y, int width, int height) {
|
public void setClip(int x, int y, int width, int height) {
|
||||||
canvasGraphics.setClip(x, y, width, height);
|
canvasGraphics.setClip(x, y, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void setColor(Color c) {
|
public void setColor(Color c) {
|
||||||
canvasGraphics.setColor(c);
|
canvasGraphics.setColor(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void setFont(Font font) {
|
public void setFont(Font font) {
|
||||||
canvasGraphics.setFont(font);
|
canvasGraphics.setFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void setPaintMode() {
|
public void setPaintMode() {
|
||||||
canvasGraphics.setPaintMode();
|
canvasGraphics.setPaintMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*{@inheritDoc}
|
|
||||||
**/
|
|
||||||
@Override
|
@Override
|
||||||
public void setXORMode(Color c1) {
|
public void setXORMode(Color c1) {
|
||||||
canvasGraphics.setXORMode(c1);
|
canvasGraphics.setXORMode(c1);
|
||||||
|
|||||||
+57
-20
@@ -1,7 +1,9 @@
|
|||||||
package com.diyfever.diylc.presenter;
|
package com.diyfever.diylc.presenter;
|
||||||
|
|
||||||
|
import java.awt.AlphaComposite;
|
||||||
import java.awt.BasicStroke;
|
import java.awt.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Composite;
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
@@ -233,6 +235,9 @@ public class Presenter implements IPlugInPort {
|
|||||||
g2dWrapper.scale(zoomLevel, zoomLevel);
|
g2dWrapper.scale(zoomLevel, zoomLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Composite mainComposite = g2d.getComposite();
|
||||||
|
Composite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
|
||||||
|
|
||||||
g2dWrapper.resetTx();
|
g2dWrapper.resetTx();
|
||||||
|
|
||||||
List<IComponentInstance> components = getCurrentProject().getComponents();
|
List<IComponentInstance> components = getCurrentProject().getComponents();
|
||||||
@@ -240,10 +245,26 @@ public class Presenter implements IPlugInPort {
|
|||||||
if (components != null) {
|
if (components != null) {
|
||||||
for (IComponentInstance component : components) {
|
for (IComponentInstance component : components) {
|
||||||
g2dWrapper.startedDrawingComponent();
|
g2dWrapper.startedDrawingComponent();
|
||||||
ComponentState state = (selectedComponents.contains(component) && drawOptions
|
ComponentState state = ComponentState.NORMAL;
|
||||||
.contains(DrawOption.SELECTION)) ? ComponentState.SELECTED
|
if (drawOptions.contains(DrawOption.SELECTION)
|
||||||
: ComponentState.NORMAL;
|
&& selectedComponents.contains(component)) {
|
||||||
|
if (dragInProgress) {
|
||||||
|
state = ComponentState.DRAGGING;
|
||||||
|
} else {
|
||||||
|
state = ComponentState.SELECTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If the component is being dragged, draw it in a separate
|
||||||
|
// composite.
|
||||||
|
if (state == ComponentState.DRAGGING) {
|
||||||
|
g2dWrapper.setComposite(alphaComposite);
|
||||||
|
}
|
||||||
|
// Draw the component through the g2dWrapper.
|
||||||
component.draw(g2dWrapper, state);
|
component.draw(g2dWrapper, state);
|
||||||
|
// Restore the composite if needed.
|
||||||
|
if (state == ComponentState.DRAGGING) {
|
||||||
|
g2dWrapper.setComposite(mainComposite);
|
||||||
|
}
|
||||||
componentAreaMap.put(component, g2dWrapper.finishedDrawingComponent());
|
componentAreaMap.put(component, g2dWrapper.finishedDrawingComponent());
|
||||||
|
|
||||||
// Draw control points
|
// Draw control points
|
||||||
@@ -404,12 +425,15 @@ public class Presenter implements IPlugInPort {
|
|||||||
dragStartPoint = point;
|
dragStartPoint = point;
|
||||||
Point scaledPoint = scalePoint(point);
|
Point scaledPoint = scalePoint(point);
|
||||||
List<IComponentInstance> components = findComponentsAt(scaledPoint);
|
List<IComponentInstance> components = findComponentsAt(scaledPoint);
|
||||||
|
// If no components are under the cursor, reset selection.
|
||||||
if (components.isEmpty()) {
|
if (components.isEmpty()) {
|
||||||
selectedComponents.clear();
|
selectedComponents.clear();
|
||||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
} else {
|
} else {
|
||||||
IComponentInstance component = components.get(0);
|
IComponentInstance component = components.get(0);
|
||||||
|
// If the component under the cursor is not already selected, make
|
||||||
|
// it into the only selected component.
|
||||||
if (!selectedComponents.contains(component)) {
|
if (!selectedComponents.contains(component)) {
|
||||||
selectedComponents.clear();
|
selectedComponents.clear();
|
||||||
selectedComponents.add(component);
|
selectedComponents.add(component);
|
||||||
@@ -421,10 +445,17 @@ public class Presenter implements IPlugInPort {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dragOver(Point point) {
|
public boolean dragOver(Point point) {
|
||||||
|
// If there's no selection, the only thing to do is update the selection
|
||||||
|
// rectangle and refresh.
|
||||||
if (selectedComponents.isEmpty()) {
|
if (selectedComponents.isEmpty()) {
|
||||||
this.selectionRect = Utils.createRectangle(point, dragStartPoint);
|
this.selectionRect = Utils.createRectangle(point, dragStartPoint);
|
||||||
messageDispatcher.dispatchMessage(EventType.SELECTION_RECT_CHANGED, selectionRect);
|
messageDispatcher.dispatchMessage(EventType.SELECTION_RECT_CHANGED, selectionRect);
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
|
} else {
|
||||||
|
// If there are components selected translate their control points.
|
||||||
|
translateSelection(point);
|
||||||
|
dragStartPoint = point;
|
||||||
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -454,26 +485,12 @@ public class Presenter implements IPlugInPort {
|
|||||||
selectionRect = null;
|
selectionRect = null;
|
||||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
||||||
} else {
|
} else {
|
||||||
|
// There is selection, so we need to finalize the drag&drop
|
||||||
|
// operation.
|
||||||
Project oldProject = cloner.deepClone(currentProject);
|
Project oldProject = cloner.deepClone(currentProject);
|
||||||
|
|
||||||
// If there are components selected translate their control points.
|
// If there are components selected translate their control points.
|
||||||
int dx = (int) ((point.x - dragStartPoint.x) / zoomLevel);
|
translateSelection(point);
|
||||||
int dy = (int) ((point.y - dragStartPoint.y) / zoomLevel);
|
|
||||||
for (IComponentInstance component : selectedComponents) {
|
|
||||||
List<ControlPointWrapper> controlPoints = ComponentProcessor.getInstance()
|
|
||||||
.extractControlPoints(component.getClass());
|
|
||||||
for (ControlPointWrapper controlPoint : controlPoints) {
|
|
||||||
try {
|
|
||||||
controlPoint.readFrom(component);
|
|
||||||
if (controlPoint.isEditable()) {
|
|
||||||
controlPoint.getValue().translate(dx, dy);
|
|
||||||
}
|
|
||||||
controlPoint.writeTo(component);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.error("Could not translate control points: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!oldProject.equals(currentProject)) {
|
if (!oldProject.equals(currentProject)) {
|
||||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
|
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
|
||||||
.deepClone(currentProject), "Move");
|
.deepClone(currentProject), "Move");
|
||||||
@@ -483,6 +500,26 @@ public class Presenter implements IPlugInPort {
|
|||||||
dragInProgress = false;
|
dragInProgress = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void translateSelection(Point toPoint) {
|
||||||
|
int dx = (int) ((toPoint.x - dragStartPoint.x) / zoomLevel);
|
||||||
|
int dy = (int) ((toPoint.y - dragStartPoint.y) / zoomLevel);
|
||||||
|
for (IComponentInstance component : selectedComponents) {
|
||||||
|
List<ControlPointWrapper> controlPoints = ComponentProcessor.getInstance()
|
||||||
|
.extractControlPoints(component.getClass());
|
||||||
|
for (ControlPointWrapper controlPoint : controlPoints) {
|
||||||
|
try {
|
||||||
|
controlPoint.readFrom(component);
|
||||||
|
if (controlPoint.isEditable()) {
|
||||||
|
controlPoint.getValue().translate(dx, dy);
|
||||||
|
}
|
||||||
|
controlPoint.writeTo(component);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("Could not translate control points: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addComponents(List<IComponentInstance> components, Point preferredPoint) {
|
public void addComponents(List<IComponentInstance> components, Point preferredPoint) {
|
||||||
LOG.debug(String.format("addComponents(%s)", components));
|
LOG.debug(String.format("addComponents(%s)", components));
|
||||||
|
|||||||
Reference in New Issue
Block a user