mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
configurable render quality
This commit is contained in:
@@ -1,14 +1,22 @@
|
|||||||
<map>
|
<map>
|
||||||
<entry>
|
<entry>
|
||||||
<string>lastPath</string>
|
<string>metric</string>
|
||||||
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop\oldFiles</string>
|
<boolean>false</boolean>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>zoom</string>
|
<string>zoom</string>
|
||||||
<double>1.0</double>
|
<double>1.0</double>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>metric</string>
|
<string>lastPath</string>
|
||||||
|
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop\oldFiles</string>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>antiAliasing</string>
|
||||||
|
<boolean>false</boolean>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>hiQualityRender</string>
|
||||||
<boolean>false</boolean>
|
<boolean>false</boolean>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
|
|||||||
Binary file not shown.
+8
-1
@@ -11,6 +11,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.swing.plugins.edit.ComponentTransferable;
|
||||||
|
|
||||||
import com.diyfever.gui.simplemq.IMessageListener;
|
import com.diyfever.gui.simplemq.IMessageListener;
|
||||||
import com.diyfever.gui.simplemq.MessageDispatcher;
|
import com.diyfever.gui.simplemq.MessageDispatcher;
|
||||||
@@ -30,7 +31,8 @@ import com.diyfever.gui.update.VersionNumber;
|
|||||||
*/
|
*/
|
||||||
public interface IPlugInPort {
|
public interface IPlugInPort {
|
||||||
|
|
||||||
public static final String CHECK_BOX_MENU_ITEM = "org.diylc.checkBoxMenuItem";
|
public static final String ANTI_ALIASING_KEY = "antiAliasing";
|
||||||
|
public static final String HI_QUALITY_RENDER_KEY = "hiQualityRender";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns size of the canvas that takes project dimensions into account as
|
* Returns size of the canvas that takes project dimensions into account as
|
||||||
@@ -328,4 +330,9 @@ public interface IPlugInPort {
|
|||||||
* Brings each of the selected components one step to front.
|
* Brings each of the selected components one step to front.
|
||||||
*/
|
*/
|
||||||
void bringSelectionToFront();
|
void bringSelectionToFront();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Causes the display to refresh.
|
||||||
|
*/
|
||||||
|
void refresh();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ public interface IView {
|
|||||||
public static final int CANCEL_OPTION = 2;
|
public static final int CANCEL_OPTION = 2;
|
||||||
public static final int OK_OPTION = 0;
|
public static final int OK_OPTION = 0;
|
||||||
|
|
||||||
|
public static final String CHECK_BOX_MENU_ITEM = "org.diylc.checkBoxMenuItem";
|
||||||
|
|
||||||
void showMessage(String message, String title, int messageType);
|
void showMessage(String message, String title, int messageType);
|
||||||
|
|
||||||
int showConfirmDialog(String message, String title, int optionType, int messageType);
|
int showConfirmDialog(String message, String title, int optionType, int messageType);
|
||||||
|
|||||||
@@ -0,0 +1,114 @@
|
|||||||
|
package org.diylc.core;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Theme implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private Color bgColor;
|
||||||
|
private Color gridColor;
|
||||||
|
private Color componentBodyColor;
|
||||||
|
private Color componentBorderColor;
|
||||||
|
private Color componentLabelColor;
|
||||||
|
|
||||||
|
public Theme(String name, Color bgColor, Color gridColor, Color componentBodyColor,
|
||||||
|
Color componentBorderColor, Color componentLabelColor) {
|
||||||
|
super();
|
||||||
|
this.name = name;
|
||||||
|
this.bgColor = bgColor;
|
||||||
|
this.gridColor = gridColor;
|
||||||
|
this.componentBodyColor = componentBodyColor;
|
||||||
|
this.componentBorderColor = componentBorderColor;
|
||||||
|
this.componentLabelColor = componentLabelColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getBgColor() {
|
||||||
|
return bgColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getGridColor() {
|
||||||
|
return gridColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getComponentBodyColor() {
|
||||||
|
return componentBodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getComponentBorderColor() {
|
||||||
|
return componentBorderColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getComponentLabelColor() {
|
||||||
|
return componentLabelColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((bgColor == null) ? 0 : bgColor.hashCode());
|
||||||
|
result = prime * result
|
||||||
|
+ ((componentBodyColor == null) ? 0 : componentBodyColor.hashCode());
|
||||||
|
result = prime * result
|
||||||
|
+ ((componentBorderColor == null) ? 0 : componentBorderColor.hashCode());
|
||||||
|
result = prime * result
|
||||||
|
+ ((componentLabelColor == null) ? 0 : componentLabelColor.hashCode());
|
||||||
|
result = prime * result + ((gridColor == null) ? 0 : gridColor.hashCode());
|
||||||
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Theme other = (Theme) obj;
|
||||||
|
if (bgColor == null) {
|
||||||
|
if (other.bgColor != null)
|
||||||
|
return false;
|
||||||
|
} else if (!bgColor.equals(other.bgColor))
|
||||||
|
return false;
|
||||||
|
if (componentBodyColor == null) {
|
||||||
|
if (other.componentBodyColor != null)
|
||||||
|
return false;
|
||||||
|
} else if (!componentBodyColor.equals(other.componentBodyColor))
|
||||||
|
return false;
|
||||||
|
if (componentBorderColor == null) {
|
||||||
|
if (other.componentBorderColor != null)
|
||||||
|
return false;
|
||||||
|
} else if (!componentBorderColor.equals(other.componentBorderColor))
|
||||||
|
return false;
|
||||||
|
if (componentLabelColor == null) {
|
||||||
|
if (other.componentLabelColor != null)
|
||||||
|
return false;
|
||||||
|
} else if (!componentLabelColor.equals(other.componentLabelColor))
|
||||||
|
return false;
|
||||||
|
if (gridColor == null) {
|
||||||
|
if (other.gridColor != null)
|
||||||
|
return false;
|
||||||
|
} else if (!gridColor.equals(other.gridColor))
|
||||||
|
return false;
|
||||||
|
if (name == null) {
|
||||||
|
if (other.name != null)
|
||||||
|
return false;
|
||||||
|
} else if (!name.equals(other.name))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
+22
-2
@@ -21,6 +21,7 @@ import org.diylc.common.DrawOption;
|
|||||||
import org.diylc.common.EventType;
|
import org.diylc.common.EventType;
|
||||||
import org.diylc.common.GridType;
|
import org.diylc.common.GridType;
|
||||||
import org.diylc.common.IComponentFiler;
|
import org.diylc.common.IComponentFiler;
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
import org.diylc.core.ComponentState;
|
import org.diylc.core.ComponentState;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
@@ -101,12 +102,27 @@ public class DrawingManager {
|
|||||||
}
|
}
|
||||||
G2DWrapper g2dWrapper = new G2DWrapper(g2d);
|
G2DWrapper g2dWrapper = new G2DWrapper(g2d);
|
||||||
|
|
||||||
if (drawOptions.contains(DrawOption.ANTIALIASING)
|
if (drawOptions.contains(DrawOption.ANTIALIASING)) {
|
||||||
&& ConfigurationManager.getInstance().readBoolean(ANTIALIASING_KEY, true)) {
|
|
||||||
g2d
|
g2d
|
||||||
.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
} else {
|
||||||
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||||
|
RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||||
}
|
}
|
||||||
|
if (ConfigurationManager.getInstance()
|
||||||
|
.readBoolean(IPlugInPort.HI_QUALITY_RENDER_KEY, false)) {
|
||||||
|
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||||
|
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||||
|
g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION,
|
||||||
|
RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
|
||||||
|
g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
|
||||||
|
RenderingHints.VALUE_COLOR_RENDER_QUALITY);
|
||||||
|
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||||
|
g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
|
||||||
|
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
|
||||||
|
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||||
|
} else {
|
||||||
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||||
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
|
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
|
||||||
g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION,
|
g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION,
|
||||||
@@ -114,6 +130,10 @@ public class DrawingManager {
|
|||||||
g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
|
g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
|
||||||
RenderingHints.VALUE_COLOR_RENDER_SPEED);
|
RenderingHints.VALUE_COLOR_RENDER_SPEED);
|
||||||
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
|
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
|
||||||
|
g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
|
||||||
|
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
|
||||||
|
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
|
||||||
|
}
|
||||||
|
|
||||||
double zoom = 1d;
|
double zoom = 1d;
|
||||||
if (drawOptions.contains(DrawOption.ZOOM)) {
|
if (drawOptions.contains(DrawOption.ZOOM)) {
|
||||||
|
|||||||
+5
@@ -978,6 +978,11 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refresh() {
|
||||||
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the selection with the specified {@link ComponentTransferable}.
|
* Updates the selection with the specified {@link ComponentTransferable}.
|
||||||
* Also, updates control point map with all components that are stuck to the
|
* Also, updates control point map with all components that are stuck to the
|
||||||
|
|||||||
+36
@@ -16,6 +16,7 @@ import org.diylc.common.IPlugInPort;
|
|||||||
import org.diylc.common.ITask;
|
import org.diylc.common.ITask;
|
||||||
import org.diylc.common.PropertyWrapper;
|
import org.diylc.common.PropertyWrapper;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
|
import org.diylc.core.IView;
|
||||||
import org.diylc.images.IconLoader;
|
import org.diylc.images.IconLoader;
|
||||||
import org.diylc.swing.gui.DialogFactory;
|
import org.diylc.swing.gui.DialogFactory;
|
||||||
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
||||||
@@ -28,6 +29,7 @@ import org.diylc.swing.plugins.file.FileFilterEnum;
|
|||||||
import com.diyfever.gui.ButtonDialog;
|
import com.diyfever.gui.ButtonDialog;
|
||||||
import com.diyfever.gui.IDrawingProvider;
|
import com.diyfever.gui.IDrawingProvider;
|
||||||
import com.diyfever.gui.export.DrawingExporter;
|
import com.diyfever.gui.export.DrawingExporter;
|
||||||
|
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||||
import com.rits.cloning.Cloner;
|
import com.rits.cloning.Cloner;
|
||||||
|
|
||||||
public class ActionFactory {
|
public class ActionFactory {
|
||||||
@@ -133,6 +135,13 @@ public class ActionFactory {
|
|||||||
return new BringToFrontAction(plugInPort);
|
return new BringToFrontAction(plugInPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Config actions.
|
||||||
|
|
||||||
|
public ConfigAction createConfigAction(IPlugInPort plugInPort, String title, String configKey,
|
||||||
|
boolean defaultValue) {
|
||||||
|
return new ConfigAction(plugInPort, title, configKey, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
// File menu actions.
|
// File menu actions.
|
||||||
|
|
||||||
public static class NewAction extends AbstractAction {
|
public static class NewAction extends AbstractAction {
|
||||||
@@ -789,4 +798,31 @@ public class ActionFactory {
|
|||||||
plugInPort.bringSelectionToFront();
|
plugInPort.bringSelectionToFront();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class ConfigAction extends AbstractAction {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private IPlugInPort plugInPort;
|
||||||
|
private String configKey;
|
||||||
|
|
||||||
|
public ConfigAction(IPlugInPort plugInPort, String title, String configKey,
|
||||||
|
boolean defaultValue) {
|
||||||
|
super();
|
||||||
|
this.plugInPort = plugInPort;
|
||||||
|
this.configKey = configKey;
|
||||||
|
putValue(AbstractAction.NAME, title);
|
||||||
|
putValue(IView.CHECK_BOX_MENU_ITEM, true);
|
||||||
|
putValue(AbstractAction.SELECTED_KEY, ConfigurationManager.getInstance().readBoolean(
|
||||||
|
configKey, defaultValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
LOG.info(getValue(AbstractAction.NAME) + " triggered");
|
||||||
|
ConfigurationManager.getInstance().writeValue(configKey,
|
||||||
|
getValue(AbstractAction.SELECTED_KEY));
|
||||||
|
plugInPort.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -33,10 +33,12 @@ import org.diylc.common.EventType;
|
|||||||
import org.diylc.common.IPlugIn;
|
import org.diylc.common.IPlugIn;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.ITask;
|
import org.diylc.common.ITask;
|
||||||
|
import org.diylc.core.IView;
|
||||||
import org.diylc.images.IconLoader;
|
import org.diylc.images.IconLoader;
|
||||||
import org.diylc.presenter.Presenter;
|
import org.diylc.presenter.Presenter;
|
||||||
import org.diylc.swing.ISwingUI;
|
import org.diylc.swing.ISwingUI;
|
||||||
import org.diylc.swing.plugins.canvas.CanvasPlugin;
|
import org.diylc.swing.plugins.canvas.CanvasPlugin;
|
||||||
|
import org.diylc.swing.plugins.config.ConfigPlugin;
|
||||||
import org.diylc.swing.plugins.edit.EditMenuPlugin;
|
import org.diylc.swing.plugins.edit.EditMenuPlugin;
|
||||||
import org.diylc.swing.plugins.file.FileMenuPlugin;
|
import org.diylc.swing.plugins.file.FileMenuPlugin;
|
||||||
import org.diylc.swing.plugins.help.HelpMenuPlugin;
|
import org.diylc.swing.plugins.help.HelpMenuPlugin;
|
||||||
@@ -78,6 +80,7 @@ public class MainFrame extends JFrame implements ISwingUI {
|
|||||||
presenter.installPlugin(new ToolBox(this));
|
presenter.installPlugin(new ToolBox(this));
|
||||||
presenter.installPlugin(new FileMenuPlugin(this));
|
presenter.installPlugin(new FileMenuPlugin(this));
|
||||||
presenter.installPlugin(new EditMenuPlugin(this));
|
presenter.installPlugin(new EditMenuPlugin(this));
|
||||||
|
presenter.installPlugin(new ConfigPlugin(this));
|
||||||
presenter.installPlugin(new LayersMenuPlugin(this));
|
presenter.installPlugin(new LayersMenuPlugin(this));
|
||||||
// presenter.installPlugin(new OnlineManager());
|
// presenter.installPlugin(new OnlineManager());
|
||||||
presenter.installPlugin(new HelpMenuPlugin(this));
|
presenter.installPlugin(new HelpMenuPlugin(this));
|
||||||
@@ -235,7 +238,7 @@ public class MainFrame extends JFrame implements ISwingUI {
|
|||||||
if (action == null) {
|
if (action == null) {
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
} else {
|
} else {
|
||||||
Boolean isCheckBox = (Boolean) action.getValue(IPlugInPort.CHECK_BOX_MENU_ITEM);
|
Boolean isCheckBox = (Boolean) action.getValue(IView.CHECK_BOX_MENU_ITEM);
|
||||||
if (isCheckBox != null && isCheckBox) {
|
if (isCheckBox != null && isCheckBox) {
|
||||||
menu.add(new JCheckBoxMenuItem(action));
|
menu.add(new JCheckBoxMenuItem(action));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+31
-22
@@ -34,6 +34,7 @@ import org.diylc.swing.gui.DialogFactory;
|
|||||||
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
||||||
|
|
||||||
import com.diyfever.gui.ButtonDialog;
|
import com.diyfever.gui.ButtonDialog;
|
||||||
|
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GUI class used to draw onto.
|
* GUI class used to draw onto.
|
||||||
@@ -52,6 +53,8 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
private static boolean USE_HARDWARE_ACCELLERATION = false;
|
private static boolean USE_HARDWARE_ACCELLERATION = false;
|
||||||
|
|
||||||
static final EnumSet<DrawOption> DRAW_OPTIONS = EnumSet.of(DrawOption.GRID,
|
static final EnumSet<DrawOption> DRAW_OPTIONS = EnumSet.of(DrawOption.GRID,
|
||||||
|
DrawOption.SELECTION, DrawOption.ZOOM, DrawOption.CONTROL_POINTS);
|
||||||
|
static final EnumSet<DrawOption> DRAW_OPTIONS_ANTI_ALIASING = EnumSet.of(DrawOption.GRID,
|
||||||
DrawOption.SELECTION, DrawOption.ZOOM, DrawOption.ANTIALIASING,
|
DrawOption.SELECTION, DrawOption.ZOOM, DrawOption.ANTIALIASING,
|
||||||
DrawOption.CONTROL_POINTS);
|
DrawOption.CONTROL_POINTS);
|
||||||
|
|
||||||
@@ -75,7 +78,8 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
private void initializeDnD() {
|
private void initializeDnD() {
|
||||||
// Initialize drag source recognizer.
|
// Initialize drag source recognizer.
|
||||||
DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(this,
|
DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(this,
|
||||||
DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK, new CanvasGestureListener(plugInPort));
|
DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_LINK,
|
||||||
|
new CanvasGestureListener(plugInPort));
|
||||||
// Initialize drop target.
|
// Initialize drop target.
|
||||||
new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE,
|
new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE,
|
||||||
new CanvasTargetListener(plugInPort), true);
|
new CanvasTargetListener(plugInPort), true);
|
||||||
@@ -104,7 +108,9 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
bufferImage = createImage(getWidth(), getHeight());
|
bufferImage = createImage(getWidth(), getHeight());
|
||||||
}
|
}
|
||||||
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
||||||
plugInPort.draw(g2d, DRAW_OPTIONS, null);
|
plugInPort.draw(g2d, ConfigurationManager.getInstance().readBoolean(
|
||||||
|
IPlugInPort.ANTI_ALIASING_KEY, true) ? DRAW_OPTIONS_ANTI_ALIASING : DRAW_OPTIONS,
|
||||||
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -116,7 +122,9 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
createBufferImage();
|
createBufferImage();
|
||||||
} else {
|
} else {
|
||||||
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
Graphics2D g2d = (Graphics2D) bufferImage.getGraphics();
|
||||||
plugInPort.draw(g2d, DRAW_OPTIONS, null);
|
plugInPort.draw(g2d, ConfigurationManager.getInstance().readBoolean(
|
||||||
|
IPlugInPort.ANTI_ALIASING_KEY, true) ? DRAW_OPTIONS_ANTI_ALIASING
|
||||||
|
: DRAW_OPTIONS, null);
|
||||||
}
|
}
|
||||||
if (USE_HARDWARE_ACCELLERATION) {
|
if (USE_HARDWARE_ACCELLERATION) {
|
||||||
VolatileImage volatileImage = (VolatileImage) bufferImage;
|
VolatileImage volatileImage = (VolatileImage) bufferImage;
|
||||||
@@ -125,10 +133,11 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
if (volatileImage.contentsLost()) {
|
if (volatileImage.contentsLost()) {
|
||||||
createBufferImage();
|
createBufferImage();
|
||||||
}
|
}
|
||||||
// int validation = volatileImage.validate(screenGraphicsConfiguration);
|
// int validation =
|
||||||
// if (validation == VolatileImage.IMAGE_INCOMPATIBLE) {
|
// volatileImage.validate(screenGraphicsConfiguration);
|
||||||
// createBufferImage();
|
// if (validation == VolatileImage.IMAGE_INCOMPATIBLE) {
|
||||||
// }
|
// createBufferImage();
|
||||||
|
// }
|
||||||
g.drawImage(bufferImage, 0, 0, this);
|
g.drawImage(bufferImage, 0, 0, this);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
createBufferImage();
|
createBufferImage();
|
||||||
@@ -136,7 +145,7 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
} while (volatileImage == null || volatileImage.contentsLost());
|
} while (volatileImage == null || volatileImage.contentsLost());
|
||||||
} else {
|
} else {
|
||||||
g.drawImage(bufferImage, 0, 0, this);
|
g.drawImage(bufferImage, 0, 0, this);
|
||||||
// bufferImage.flush();
|
// bufferImage.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,18 +163,18 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// addKeyListener(new KeyAdapter() {
|
// addKeyListener(new KeyAdapter() {
|
||||||
//
|
//
|
||||||
// @Override
|
// @Override
|
||||||
// public void keyPressed(KeyEvent e) {
|
// public void keyPressed(KeyEvent e) {
|
||||||
// if (e.getKeyCode() == KeyEvent.VK_DELETE) {
|
// if (e.getKeyCode() == KeyEvent.VK_DELETE) {
|
||||||
// plugInPort.deleteSelectedComponents();
|
// plugInPort.deleteSelectedComponents();
|
||||||
// }
|
// }
|
||||||
// // plugInPort.mouseMoved(getMousePosition(), e.isControlDown(),
|
// // plugInPort.mouseMoved(getMousePosition(), e.isControlDown(),
|
||||||
// // e.isShiftDown(), e
|
// // e.isShiftDown(), e
|
||||||
// // .isAltDown());
|
// // .isAltDown());
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
addMouseMotionListener(new MouseAdapter() {
|
addMouseMotionListener(new MouseAdapter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -217,8 +226,8 @@ class CanvasPanel extends JComponent implements Autoscroll {
|
|||||||
// Save default values.
|
// Save default values.
|
||||||
for (PropertyWrapper property : editor.getDefaultedProperties()) {
|
for (PropertyWrapper property : editor.getDefaultedProperties()) {
|
||||||
if (property.getValue() != null) {
|
if (property.getValue() != null) {
|
||||||
plugInPort.setSelectionDefaultPropertyValue(property.getName(),
|
plugInPort.setSelectionDefaultPropertyValue(property
|
||||||
property.getValue());
|
.getName(), property.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
package org.diylc.swing.plugins.config;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
import org.diylc.common.EventType;
|
||||||
|
import org.diylc.common.IPlugIn;
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
|
import org.diylc.swing.ActionFactory;
|
||||||
|
import org.diylc.swing.ISwingUI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls configuration menu.
|
||||||
|
*
|
||||||
|
* @author Branislav Stojkovic
|
||||||
|
*/
|
||||||
|
public class ConfigPlugin implements IPlugIn {
|
||||||
|
|
||||||
|
private static final String CONFIG_MENU = "Config";
|
||||||
|
|
||||||
|
private ISwingUI swingUI;
|
||||||
|
|
||||||
|
public ConfigPlugin(ISwingUI swingUI) {
|
||||||
|
super();
|
||||||
|
this.swingUI = swingUI;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connect(IPlugInPort plugInPort) {
|
||||||
|
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
|
||||||
|
"Anti-Aliasing", IPlugInPort.ANTI_ALIASING_KEY, true), CONFIG_MENU);
|
||||||
|
swingUI.injectMenuAction(ActionFactory.getInstance().createConfigAction(plugInPort,
|
||||||
|
"Hi-Quality Rendering", IPlugInPort.HI_QUALITY_RENDER_KEY, false), CONFIG_MENU);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumSet<EventType> getSubscribedEventTypes() {
|
||||||
|
return EnumSet.noneOf(EventType.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processMessage(EventType eventType, Object... params) {
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-1
@@ -13,6 +13,7 @@ import org.diylc.common.EventType;
|
|||||||
import org.diylc.common.IPlugIn;
|
import org.diylc.common.IPlugIn;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
|
import org.diylc.core.IView;
|
||||||
import org.diylc.swing.ISwingUI;
|
import org.diylc.swing.ISwingUI;
|
||||||
|
|
||||||
public class LayersMenuPlugin implements IPlugIn {
|
public class LayersMenuPlugin implements IPlugIn {
|
||||||
@@ -36,7 +37,7 @@ public class LayersMenuPlugin implements IPlugIn {
|
|||||||
(Boolean) getValue(Action.SELECTED_KEY));
|
(Boolean) getValue(Action.SELECTED_KEY));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
action.putValue(IPlugInPort.CHECK_BOX_MENU_ITEM, true);
|
action.putValue(IView.CHECK_BOX_MENU_ITEM, true);
|
||||||
lockActionMap.put(layer, action);
|
lockActionMap.put(layer, action);
|
||||||
swingUI.injectMenuAction(action, LOCK_LAYERS_TITLE);
|
swingUI.injectMenuAction(action, LOCK_LAYERS_TITLE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,6 +195,10 @@
|
|||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Added few types of trimmers</description>
|
<description>Added few types of trimmers</description>
|
||||||
</com.diyfever.gui.update.Change>
|
</com.diyfever.gui.update.Change>
|
||||||
|
<com.diyfever.gui.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>Configurable rendering quality to improve speed</description>
|
||||||
|
</com.diyfever.gui.update.Change>
|
||||||
</changes>
|
</changes>
|
||||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list
|
<url>http://code.google.com/p/diy-layout-creator/downloads/list
|
||||||
</url>
|
</url>
|
||||||
|
|||||||
Reference in New Issue
Block a user