mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
This commit is contained in:
@@ -20,12 +20,12 @@
|
|||||||
</entry>
|
</entry>
|
||||||
</map>
|
</map>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
|
||||||
<string>metric</string>
|
|
||||||
<boolean>true</boolean>
|
|
||||||
</entry>
|
|
||||||
<entry>
|
<entry>
|
||||||
<string>lastPath</string>
|
<string>lastPath</string>
|
||||||
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop</string>
|
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop</string>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>metric</string>
|
||||||
|
<boolean>true</boolean>
|
||||||
|
</entry>
|
||||||
</map>
|
</map>
|
||||||
+12
-8
@@ -110,15 +110,19 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
createBufferImage();
|
createBufferImage();
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
if (bufferImage.contentsLost()) {
|
try {
|
||||||
createBufferImage();
|
if (bufferImage.contentsLost()) {
|
||||||
|
createBufferImage();
|
||||||
|
}
|
||||||
|
int validation = bufferImage.validate(screenGraphicsConfiguration);
|
||||||
|
if (validation == VolatileImage.IMAGE_INCOMPATIBLE) {
|
||||||
|
createBufferImage();
|
||||||
|
}
|
||||||
|
g.drawImage(bufferImage, 0, 0, this);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
// Do nothing, it will be recreated in the next pass.
|
||||||
}
|
}
|
||||||
int validation = bufferImage.validate(screenGraphicsConfiguration);
|
} while (bufferImage == null || bufferImage.contentsLost());
|
||||||
if (validation == VolatileImage.IMAGE_INCOMPATIBLE) {
|
|
||||||
createBufferImage();
|
|
||||||
}
|
|
||||||
g.drawImage(bufferImage, 0, 0, this);
|
|
||||||
} while (bufferImage.contentsLost());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+4
-2
@@ -6,6 +6,8 @@ import java.util.EnumSet;
|
|||||||
|
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.diyfever.diylc.common.BadPositionException;
|
import com.diyfever.diylc.common.BadPositionException;
|
||||||
import com.diyfever.diylc.common.EventType;
|
import com.diyfever.diylc.common.EventType;
|
||||||
import com.diyfever.diylc.common.IPlugIn;
|
import com.diyfever.diylc.common.IPlugIn;
|
||||||
@@ -17,7 +19,7 @@ import com.diyfever.gui.ruler.RulerScrollPane;
|
|||||||
|
|
||||||
public class CanvasPlugin implements IPlugIn {
|
public class CanvasPlugin implements IPlugIn {
|
||||||
|
|
||||||
// private static final Logger LOG = Logger.getLogger(CanvasPlugin.class);
|
private static final Logger LOG = Logger.getLogger(CanvasPlugin.class);
|
||||||
|
|
||||||
private static final String METRIC_KEY = "metric";
|
private static final String METRIC_KEY = "metric";
|
||||||
|
|
||||||
@@ -35,7 +37,7 @@ public class CanvasPlugin implements IPlugIn {
|
|||||||
try {
|
try {
|
||||||
plugInPort.injectGUIComponent(getScrollPane(), SwingConstants.CENTER);
|
plugInPort.injectGUIComponent(getScrollPane(), SwingConstants.CENTER);
|
||||||
} catch (BadPositionException e) {
|
} catch (BadPositionException e) {
|
||||||
e.printStackTrace();
|
LOG.error("Could not install canvas plugin", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-5
@@ -453,7 +453,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
} else {
|
} else {
|
||||||
// If there are components selected translate their control points.
|
// If there are components selected translate their control points.
|
||||||
translateSelection(point);
|
translateSelection(dragStartPoint, point);
|
||||||
dragStartPoint = point;
|
dragStartPoint = point;
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
}
|
}
|
||||||
@@ -490,7 +490,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
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.
|
||||||
translateSelection(point);
|
translateSelection(dragStartPoint, point);
|
||||||
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");
|
||||||
@@ -500,9 +500,13 @@ public class Presenter implements IPlugInPort {
|
|||||||
dragInProgress = false;
|
dragInProgress = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void translateSelection(Point toPoint) {
|
private void translateSelection(Point fromPoint, Point toPoint) {
|
||||||
int dx = (int) ((toPoint.x - dragStartPoint.x) / zoomLevel);
|
if (toPoint == null) {
|
||||||
int dy = (int) ((toPoint.y - dragStartPoint.y) / zoomLevel);
|
LOG.debug("Drag ended outside the drawing area.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int dx = (int) ((toPoint.x - fromPoint.x) / zoomLevel);
|
||||||
|
int dy = (int) ((toPoint.y - fromPoint.y) / zoomLevel);
|
||||||
for (IComponentInstance component : selectedComponents) {
|
for (IComponentInstance component : selectedComponents) {
|
||||||
List<ControlPointWrapper> controlPoints = ComponentProcessor.getInstance()
|
List<ControlPointWrapper> controlPoints = ComponentProcessor.getInstance()
|
||||||
.extractControlPoints(component.getClass());
|
.extractControlPoints(component.getClass());
|
||||||
|
|||||||
Reference in New Issue
Block a user