mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
better scaling
added marshall board and trimmer
This commit is contained in:
+2
-2
@@ -13,8 +13,8 @@ public class CalcUtils {
|
||||
* @return
|
||||
*/
|
||||
public static int roundToGrid(int x, Size gridSpacing) {
|
||||
int grid = gridSpacing.convertToPixels();
|
||||
return (Math.round(1f * x / grid) * grid);
|
||||
double grid = gridSpacing.convertToPixels();
|
||||
return (int) (Math.round(1f * x / grid) * grid);
|
||||
}
|
||||
|
||||
public static void snapPointToGrid(Point point, Size gridSpacing) {
|
||||
|
||||
+1
-1
@@ -331,7 +331,7 @@ public class DrawingManager {
|
||||
|
||||
public Dimension getCanvasDimensions(Project project, Double zoomLevel, boolean useZoom) {
|
||||
double width = project.getWidth().convertToPixels();
|
||||
int height = project.getHeight().convertToPixels();
|
||||
double height = project.getHeight().convertToPixels();
|
||||
if (useZoom) {
|
||||
width *= zoomLevel;
|
||||
height *= zoomLevel;
|
||||
|
||||
+2
-2
@@ -815,8 +815,8 @@ public class Presenter implements IPlugInPort {
|
||||
for (IDIYComponent<?> component : components) {
|
||||
for (int i = 0; i < component.getControlPointCount(); i++) {
|
||||
Point point = new Point(component.getControlPoint(i));
|
||||
point.translate(currentProject.getGridSpacing().convertToPixels(), currentProject
|
||||
.getGridSpacing().convertToPixels());
|
||||
point.translate((int) currentProject.getGridSpacing().convertToPixels(),
|
||||
(int) currentProject.getGridSpacing().convertToPixels());
|
||||
component.setControlPoint(point, i);
|
||||
}
|
||||
addComponent(component, ComponentProcessor.getInstance().extractComponentTypeFrom(
|
||||
|
||||
+6
-11
@@ -161,8 +161,8 @@ public class ProjectFileManager {
|
||||
int height = Integer.parseInt(root.getAttribute("Height")) + 1;
|
||||
int boardWidth = (int) (width * Constants.PIXELS_PER_INCH * V1_GRID_SPACING.getValue());
|
||||
int boardHeight = (int) (height * Constants.PIXELS_PER_INCH * V1_GRID_SPACING.getValue());
|
||||
int projectWidth = project.getWidth().convertToPixels();
|
||||
int projectHeight = project.getHeight().convertToPixels();
|
||||
int projectWidth = (int) project.getWidth().convertToPixels();
|
||||
int projectHeight = (int) project.getHeight().convertToPixels();
|
||||
int x = (projectWidth - boardWidth) / 2;
|
||||
int y = (projectHeight - boardHeight) / 2;
|
||||
AbstractBoard board;
|
||||
@@ -178,11 +178,11 @@ public class ProjectFileManager {
|
||||
throw new IllegalArgumentException("Unrecognized board type: " + type);
|
||||
}
|
||||
board.setName("Main board");
|
||||
Point referencePoint = new Point(roundToGrid(x, V1_GRID_SPACING), roundToGrid(y,
|
||||
V1_GRID_SPACING));
|
||||
Point referencePoint = new Point(CalcUtils.roundToGrid(x, V1_GRID_SPACING), CalcUtils
|
||||
.roundToGrid(y, V1_GRID_SPACING));
|
||||
board.setControlPoint(referencePoint, 0);
|
||||
board.setControlPoint(new Point(roundToGrid(x + boardWidth, V1_GRID_SPACING), roundToGrid(y
|
||||
+ boardHeight, V1_GRID_SPACING)), 1);
|
||||
board.setControlPoint(new Point(CalcUtils.roundToGrid(x + boardWidth, V1_GRID_SPACING),
|
||||
CalcUtils.roundToGrid(y + boardHeight, V1_GRID_SPACING)), 1);
|
||||
project.getComponents().add(board);
|
||||
|
||||
NodeList childNodes = root.getChildNodes();
|
||||
@@ -435,9 +435,4 @@ public class ProjectFileManager {
|
||||
fis.close();
|
||||
return project;
|
||||
}
|
||||
|
||||
public int roundToGrid(int x, Size gridSpacing) {
|
||||
int grid = gridSpacing.convertToPixels();
|
||||
return (Math.round(1f * x / grid) * grid);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user