mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
show selection bounds on rulers
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package org.diylc.common;
|
package org.diylc.common;
|
||||||
|
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -25,7 +26,8 @@ public interface ISelectionProcessor {
|
|||||||
void updateSelection(Collection<IDIYComponent<?>> newSelection);
|
void updateSelection(Collection<IDIYComponent<?>> newSelection);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all components at the specified location, sorted by z-index from top to bottom.
|
* Finds all components at the specified location, sorted by z-index from top to bottom. Location
|
||||||
|
* depends on the current zoom level.
|
||||||
*
|
*
|
||||||
* @param point
|
* @param point
|
||||||
* @return
|
* @return
|
||||||
@@ -54,7 +56,7 @@ public interface ISelectionProcessor {
|
|||||||
* @param direction 1 for clockwise, -1 for counter-clockwise
|
* @param direction 1 for clockwise, -1 for counter-clockwise
|
||||||
*/
|
*/
|
||||||
void rotateSelection(int direction);
|
void rotateSelection(int direction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Groups all selected components.
|
* Groups all selected components.
|
||||||
*/
|
*/
|
||||||
@@ -64,6 +66,19 @@ public interface ISelectionProcessor {
|
|||||||
* Ungroups all selected components.
|
* Ungroups all selected components.
|
||||||
*/
|
*/
|
||||||
void ungroupSelectedComponents();
|
void ungroupSelectedComponents();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mirrors selected components in the given axis.
|
||||||
|
*
|
||||||
|
* @param direction
|
||||||
|
*/
|
||||||
void mirrorSelection(int direction);
|
void mirrorSelection(int direction);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the minimum rectangle containing all selected components, or null if none exists.
|
||||||
|
* Rectangle is scaled by the current zoom level.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Rectangle2D getSelectionBounds();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.dnd.DnDConstants;
|
import java.awt.dnd.DnDConstants;
|
||||||
|
import java.awt.geom.AffineTransform;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@@ -813,6 +815,26 @@ public class Presenter implements IPlugInPort {
|
|||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Rectangle2D getSelectionBounds() {
|
||||||
|
if (selectedComponents == null || selectedComponents.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Area totalArea = new Area();
|
||||||
|
for (IDIYComponent<?> c : selectedComponents) {
|
||||||
|
Area compArea = drawingManager.getComponentArea(c);
|
||||||
|
if (compArea != null)
|
||||||
|
totalArea.add(compArea);
|
||||||
|
else
|
||||||
|
LOG.info("Area is null");
|
||||||
|
}
|
||||||
|
if (drawingManager.getZoomLevel() != 1) {
|
||||||
|
totalArea
|
||||||
|
.transform(AffineTransform.getScaleInstance(drawingManager.getZoomLevel(), drawingManager.getZoomLevel()));
|
||||||
|
}
|
||||||
|
return totalArea.getBounds2D();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VersionNumber getCurrentVersionNumber() {
|
public VersionNumber getCurrentVersionNumber() {
|
||||||
return CURRENT_VERSION;
|
return CURRENT_VERSION;
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -550,6 +550,16 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
|
|||||||
break;
|
break;
|
||||||
case REPAINT:
|
case REPAINT:
|
||||||
canvasPanel.repaint();
|
canvasPanel.repaint();
|
||||||
|
// Refresh selection bounds after we're done with painting to ensure we have traced the
|
||||||
|
// component areas
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.SHOW_RULERS_KEY, true))
|
||||||
|
scrollPane.setSelectionRectangle(plugInPort.getSelectionBounds());
|
||||||
|
}
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -1692,6 +1692,22 @@
|
|||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
</changes>
|
</changes>
|
||||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||||
|
</org.diylc.appframework.update.Version>
|
||||||
|
<org.diylc.appframework.update.Version>
|
||||||
|
<versionNumber>
|
||||||
|
<major>3</major>
|
||||||
|
<minor>39</minor>
|
||||||
|
<build>0</build>
|
||||||
|
</versionNumber>
|
||||||
|
<releaseDate>2017-04-20 20:00:00.000 CET</releaseDate>
|
||||||
|
<name></name>
|
||||||
|
<changes>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>Red ticks on both rulers track selection bounds, blue tick tracks cursor position</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
|
</changes>
|
||||||
|
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||||
</org.diylc.appframework.update.Version>
|
</org.diylc.appframework.update.Version>
|
||||||
</a>
|
</a>
|
||||||
</java.util.Arrays_-ArrayList>
|
</java.util.Arrays_-ArrayList>
|
||||||
Reference in New Issue
Block a user