Skip to content

Commit

Permalink
Issue 107 - use a default DPI in case JavaFX reports 0
Browse files Browse the repository at this point in the history
  • Loading branch information
tbee committed Aug 31, 2024
1 parent 06b7ba1 commit 23ece50
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.miglayout</groupId>
<artifactId>miglayout-parent</artifactId>
<version>11.4</version>
<version>11.4.1-SNAPSHOT</version>
</parent>
<artifactId>miglayout-core</artifactId>
<name>MiGLayout Core</name>
Expand Down
2 changes: 1 addition & 1 deletion demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.miglayout</groupId>
<artifactId>miglayout-parent</artifactId>
<version>11.4</version>
<version>11.4.1-SNAPSHOT</version>
</parent>
<artifactId>miglayout-demo</artifactId>
<name>MiGLayout Demo</name>
Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.miglayout</groupId>
<artifactId>miglayout-parent</artifactId>
<version>11.4</version>
<version>11.4.1-SNAPSHOT</version>
</parent>
<artifactId>miglayout-examples</artifactId>
<name>MiGLayout Examples</name>
Expand Down
2 changes: 1 addition & 1 deletion javafx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.miglayout</groupId>
<artifactId>miglayout-parent</artifactId>
<version>11.4</version>
<version>11.4.1-SNAPSHOT</version>
</parent>
<artifactId>miglayout-javafx</artifactId>
<name>MiGLayout JavaFX</name>
Expand Down
19 changes: 14 additions & 5 deletions javafx/src/main/java/org/tbee/javafx/scene/layout/MigPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -972,14 +972,22 @@ public int[] getVisualPadding()
public int getHorizontalScreenDPI()
{
// todo All references to Screen.getPrimary() should be replaced with getting the actual screen the Node is on.
return (int) Math.ceil(Screen.getPrimary().getDpi());
double dpi = Screen.getPrimary().getDpi();
if (dpi < 1.0) {
dpi = 96.0;
}
return (int) Math.ceil(dpi);
}

@Override
public int getVerticalScreenDPI()
{
// todo All references to Screen.getPrimary() should be replaced with getting the actual screen the Node is on.
return (int) Math.ceil(Screen.getPrimary().getDpi());
double dpi = Screen.getPrimary().getDpi();
if (dpi < 1.0) {
dpi = 96.0;
}
return (int) Math.ceil(dpi);
}

@Override
Expand Down Expand Up @@ -1058,9 +1066,10 @@ public boolean equals(Object o)
@Override
public void setBounds(int x, int y, int width, int height)
{
// System.out.println(getComponent() + " FXComponentWrapper.setBound x=" + x + ",y=" + y + " / w=" + width + ",h=" + height + " / resizable=" + this.node.isResizable());
// System.out.println("x: " + x + ", y: " + y);
// CC cc = wrapperToCCMap.get(this);
// TBEERNOT
System.out.println(getComponent() + " FXComponentWrapper.setBound x=" + x + ",y=" + y + " / w=" + width + ",h=" + height + " / resizable=" + this.node.isResizable());
//System.out.println("x: " + x + ", y: " + y);
//CC cc = wrapperToCCMap.get(this);

if (!animateBoundsChange(node, x, y, width, height)) {
node.resizeRelocate((double) x, (double) y, (double) width, (double) height);
Expand Down
2 changes: 1 addition & 1 deletion nbm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.miglayout</groupId>
<artifactId>miglayout-parent</artifactId>
<version>11.4</version>
<version>11.4.1-SNAPSHOT</version>
</parent>

<artifactId>lib-miglayout-NB90</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>
<groupId>com.miglayout</groupId>
<artifactId>miglayout-parent</artifactId>
<version>11.4</version>
<version>11.4.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>MiGLayout</name>
<description>MiGLayout - Java Layout Manager for Swing, SWT and JavaFX</description>
Expand Down
2 changes: 1 addition & 1 deletion swing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.miglayout</groupId>
<artifactId>miglayout-parent</artifactId>
<version>11.4</version>
<version>11.4.1-SNAPSHOT</version>
</parent>
<artifactId>miglayout-swing</artifactId>
<name>MiGLayout Swing</name>
Expand Down
2 changes: 1 addition & 1 deletion swt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.miglayout</groupId>
<artifactId>miglayout-parent</artifactId>
<version>11.4</version>
<version>11.4.1-SNAPSHOT</version>
</parent>
<artifactId>miglayout-swt</artifactId>
<name>MiGLayout SWT</name>
Expand Down

0 comments on commit 23ece50

Please sign in to comment.