mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Merge branch 'refactor/maven' into feature/multimeter3
This commit is contained in:
@@ -279,6 +279,7 @@ Heaters
|
||||
Height
|
||||
Help
|
||||
Hi-Quality Rendering
|
||||
High DPI Rendering
|
||||
Highlight Connected Areas
|
||||
Hole
|
||||
Hole Size
|
||||
|
||||
@@ -42,6 +42,7 @@ import javax.swing.AbstractAction;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.KeyStroke;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.appframework.miscutils.IConfigListener;
|
||||
import org.diylc.appframework.miscutils.IConfigurationManager;
|
||||
|
||||
import org.diylc.common.ComponentType;
|
||||
@@ -98,6 +99,15 @@ public class CanvasPanel extends JComponent implements Autoscroll {
|
||||
// GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices();
|
||||
// screenGraphicsConfiguration = devices[0].getDefaultConfiguration();
|
||||
|
||||
configManager.addConfigListener(IPlugInPort.HIGH_DPI_RENDERING,
|
||||
new IConfigListener() {
|
||||
|
||||
@Override
|
||||
public void valueChanged(String key, Object value) {
|
||||
bufferImage = null;
|
||||
}
|
||||
});
|
||||
|
||||
initializeActions();
|
||||
}
|
||||
|
||||
@@ -311,8 +321,12 @@ public class CanvasPanel extends JComponent implements Autoscroll {
|
||||
}
|
||||
|
||||
final Graphics2D g2d = (Graphics2D)g;
|
||||
double scaleFactor = Math.sqrt(g2d.getTransform().getDeterminant());
|
||||
// scaleFactor = 1d;
|
||||
double scaleFactor;
|
||||
if (configManager.readBoolean(IPlugInPort.HIGH_DPI_RENDERING, false)) {
|
||||
scaleFactor = Math.sqrt(g2d.getTransform().getDeterminant());
|
||||
} else {
|
||||
scaleFactor = 1d;
|
||||
}
|
||||
|
||||
Rectangle visibleRect = getVisibleRect();
|
||||
|
||||
@@ -324,28 +338,9 @@ public class CanvasPanel extends JComponent implements Autoscroll {
|
||||
double x = visibleRect.x;// / scaleFactor;
|
||||
double y = visibleRect.y;// / scaleFactor;
|
||||
bufferG2d.translate(-x, -y);
|
||||
bufferG2d.setClip(visibleRect);
|
||||
|
||||
Set<DrawOption> drawOptions =
|
||||
EnumSet.of(DrawOption.SELECTION, DrawOption.ZOOM, DrawOption.CONTROL_POINTS);
|
||||
|
||||
if (configManager.readBoolean(IPlugInPort.ANTI_ALIASING_KEY, true)) {
|
||||
drawOptions.add(DrawOption.ANTIALIASING);
|
||||
}
|
||||
if (configManager.readBoolean(IPlugInPort.OUTLINE_KEY, false)) {
|
||||
drawOptions.add(DrawOption.OUTLINE_MODE);
|
||||
}
|
||||
if (configManager.readBoolean(IPlugInPort.SHOW_GRID_KEY, true)) {
|
||||
drawOptions.add(DrawOption.GRID);
|
||||
}
|
||||
if (configManager.readBoolean(IPlugInPort.EXTRA_SPACE_KEY, true)) {
|
||||
drawOptions.add(DrawOption.EXTRA_SPACE);
|
||||
}
|
||||
if (configManager.readBoolean(IPlugInPort.CACHING_ENABLED_KEY, true)) {
|
||||
drawOptions.add(DrawOption.ENABLE_CACHING);
|
||||
}
|
||||
if (configManager.readBoolean(IPlugInPort.LOCKED_ALPHA, true)) {
|
||||
drawOptions.add(DrawOption.LOCKED_ALPHA);
|
||||
}
|
||||
Set<DrawOption> drawOptions = getDrawOptions();
|
||||
|
||||
plugInPort.draw(bufferG2d, drawOptions, null, null, scaleFactor, visibleRect);
|
||||
|
||||
@@ -375,6 +370,31 @@ public class CanvasPanel extends JComponent implements Autoscroll {
|
||||
bufferG2d.dispose();
|
||||
}
|
||||
|
||||
private Set<DrawOption> getDrawOptions() {
|
||||
Set<DrawOption> drawOptions =
|
||||
EnumSet.of(DrawOption.SELECTION, DrawOption.ZOOM, DrawOption.CONTROL_POINTS);
|
||||
|
||||
if (configManager.readBoolean(IPlugInPort.ANTI_ALIASING_KEY, true)) {
|
||||
drawOptions.add(DrawOption.ANTIALIASING);
|
||||
}
|
||||
if (configManager.readBoolean(IPlugInPort.OUTLINE_KEY, false)) {
|
||||
drawOptions.add(DrawOption.OUTLINE_MODE);
|
||||
}
|
||||
if (configManager.readBoolean(IPlugInPort.SHOW_GRID_KEY, true)) {
|
||||
drawOptions.add(DrawOption.GRID);
|
||||
}
|
||||
if (configManager.readBoolean(IPlugInPort.EXTRA_SPACE_KEY, true)) {
|
||||
drawOptions.add(DrawOption.EXTRA_SPACE);
|
||||
}
|
||||
if (configManager.readBoolean(IPlugInPort.CACHING_ENABLED_KEY, true)) {
|
||||
drawOptions.add(DrawOption.ENABLE_CACHING);
|
||||
}
|
||||
if (configManager.readBoolean(IPlugInPort.LOCKED_ALPHA, true)) {
|
||||
drawOptions.add(DrawOption.LOCKED_ALPHA);
|
||||
}
|
||||
return drawOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Graphics g) {
|
||||
paint(g);
|
||||
|
||||
@@ -100,6 +100,9 @@ public class ConfigPlugin implements IPlugIn {
|
||||
// swingUI.injectMenuAction(
|
||||
// ActionFactory.getInstance().createConfigAction(plugInPort, "Hardware Acceleration", IPlugInPort.HARDWARE_ACCELERATION, false),
|
||||
// CONFIG_MENU);
|
||||
swingUI.injectMenuAction(
|
||||
ActionFactory.getInstance().createConfigAction(plugInPort, "High DPI Rendering",
|
||||
IPlugInPort.HIGH_DPI_RENDERING, false), CONFIG_MENU);
|
||||
swingUI.injectMenuAction(
|
||||
ActionFactory.getInstance().createConfigAction(plugInPort, "Hi-Quality Rendering",
|
||||
IPlugInPort.HI_QUALITY_RENDER_KEY, false), CONFIG_MENU);
|
||||
|
||||
Reference in New Issue
Block a user