mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
show selection size on demand
removed scroll buttons in toolbox
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
<map>
|
<map>
|
||||||
<entry>
|
<entry>
|
||||||
<string>metric</string>
|
<string>lastPath</string>
|
||||||
<boolean>true</boolean>
|
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop\oldFiles</string>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>zoom</string>
|
<string>zoom</string>
|
||||||
<double>1.0</double>
|
<double>1.0</double>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>lastPath</string>
|
<string>metric</string>
|
||||||
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop</string>
|
<boolean>true</boolean>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>default.org.diylc.components.misc.Label:Color</string>
|
<string>default.org.diylc.components.misc.Label:Color</string>
|
||||||
|
|||||||
-4
@@ -48,10 +48,6 @@ public enum EventType {
|
|||||||
* object containing selection size (x = width, y = height). Size is
|
* object containing selection size (x = width, y = height). Size is
|
||||||
* expressed in the default measure (cm for metric, inches for imperial).
|
* expressed in the default measure (cm for metric, inches for imperial).
|
||||||
*/
|
*/
|
||||||
SELECTION_SIZE_CHANGED,
|
|
||||||
/**
|
|
||||||
* Called when display needs to be repainted. No parameters are passed.
|
|
||||||
*/
|
|
||||||
REPAINT,
|
REPAINT,
|
||||||
/**
|
/**
|
||||||
* Called when new component slot has been changed. The only parameter is
|
* Called when new component slot has been changed. The only parameter is
|
||||||
|
|||||||
+9
-2
@@ -4,6 +4,7 @@ import java.awt.Cursor;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
|
import java.awt.geom.Point2D;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -28,7 +29,7 @@ import com.diyfever.gui.update.VersionNumber;
|
|||||||
* @see EventType
|
* @see EventType
|
||||||
*/
|
*/
|
||||||
public interface IPlugInPort {
|
public interface IPlugInPort {
|
||||||
|
|
||||||
public static final String CHECK_BOX_MENU_ITEM = "org.diylc.checkBoxMenuItem";
|
public static final String CHECK_BOX_MENU_ITEM = "org.diylc.checkBoxMenuItem";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -302,6 +303,12 @@ public interface IPlugInPort {
|
|||||||
* Ungroups all selected components.
|
* Ungroups all selected components.
|
||||||
*/
|
*/
|
||||||
void ungroupSelectedComponents();
|
void ungroupSelectedComponents();
|
||||||
|
|
||||||
void setLayerLocked(int layerZOrder, boolean locked);
|
void setLayerLocked(int layerZOrder, boolean locked);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return selection size expressed in either inches or centimeters, based
|
||||||
|
* on the user preference.
|
||||||
|
*/
|
||||||
|
Point2D calculateSelectionDimension();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ public enum IconLoader {
|
|||||||
"faq.png"), Component("component.png"), Plugin("plugin.png"), Manual("manual.png"), Donate(
|
"faq.png"), Component("component.png"), Plugin("plugin.png"), Manual("manual.png"), Donate(
|
||||||
"donate.png"), Bug("bug.png"), IconLarge("icon_large.png"), IconMedium(
|
"donate.png"), Bug("bug.png"), IconLarge("icon_large.png"), IconMedium(
|
||||||
"icon_medium.png"), IconSmall("icon_small.png"), DocumentEdit("document_edit.png"), EditComponent(
|
"icon_medium.png"), IconSmall("icon_small.png"), DocumentEdit("document_edit.png"), EditComponent(
|
||||||
"edit_component.png");
|
"edit_component.png"), Size("size.png");
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 550 B |
+2
-17
@@ -729,8 +729,6 @@ public class Presenter implements IPlugInPort {
|
|||||||
if (repaint) {
|
if (repaint) {
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
}
|
}
|
||||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
|
||||||
calculateSelectionDimension());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -841,8 +839,6 @@ public class Presenter implements IPlugInPort {
|
|||||||
@Override
|
@Override
|
||||||
public void setMetric(boolean isMetric) {
|
public void setMetric(boolean isMetric) {
|
||||||
ConfigurationManager.getInstance().writeValue(Presenter.METRIC_KEY, isMetric);
|
ConfigurationManager.getInstance().writeValue(Presenter.METRIC_KEY, isMetric);
|
||||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
|
||||||
calculateSelectionDimension());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -909,12 +905,6 @@ public class Presenter implements IPlugInPort {
|
|||||||
includeStuckComponents(controlPointMap);
|
includeStuckComponents(controlPointMap);
|
||||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents,
|
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents,
|
||||||
controlPointMap.keySet());
|
controlPointMap.keySet());
|
||||||
fireSelectionSizeChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fireSelectionSizeChanged() {
|
|
||||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
|
||||||
calculateSelectionDimension());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -956,11 +946,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
return components;
|
return components;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* @return selection size expressed in either inches or centimeters, based
|
public Point2D calculateSelectionDimension() {
|
||||||
* on the user preference.
|
|
||||||
*/
|
|
||||||
private Point2D calculateSelectionDimension() {
|
|
||||||
if (selectedComponents.isEmpty()) {
|
if (selectedComponents.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -1041,8 +1028,6 @@ public class Presenter implements IPlugInPort {
|
|||||||
projectFileManager.notifyFileChange();
|
projectFileManager.notifyFileChange();
|
||||||
}
|
}
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
|
||||||
calculateSelectionDimension());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+30
-25
@@ -6,6 +6,8 @@ import java.awt.GridBagLayout;
|
|||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.Format;
|
import java.text.Format;
|
||||||
@@ -20,9 +22,9 @@ import java.util.Map;
|
|||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.UIManager;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.diylc.common.BadPositionException;
|
import org.diylc.common.BadPositionException;
|
||||||
@@ -32,9 +34,9 @@ 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.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.gui.MainFrame;
|
|
||||||
|
|
||||||
import com.diyfever.gui.MemoryBar;
|
import com.diyfever.gui.MemoryBar;
|
||||||
import com.diyfever.gui.miscutils.ConfigurationManager;
|
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||||
@@ -45,7 +47,7 @@ import com.diyfever.gui.update.UpdateLabel;
|
|||||||
public class StatusBar extends JPanel implements IPlugIn {
|
public class StatusBar extends JPanel implements IPlugIn {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static final Logger LOG = Logger.getLogger(StatusBar.class);
|
private static final Logger LOG = Logger.getLogger(StatusBar.class);
|
||||||
|
|
||||||
public static String UPDATE_URL = "http://www.diy-fever.com/update.xml";
|
public static String UPDATE_URL = "http://www.diy-fever.com/update.xml";
|
||||||
@@ -70,7 +72,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
super();
|
super();
|
||||||
|
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
swingUI.injectGUIComponent(this, SwingUtilities.BOTTOM);
|
swingUI.injectGUIComponent(this, SwingUtilities.BOTTOM);
|
||||||
} catch (BadPositionException e) {
|
} catch (BadPositionException e) {
|
||||||
@@ -123,11 +125,27 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
|
|
||||||
public JLabel getSizeLabel() {
|
public JLabel getSizeLabel() {
|
||||||
if (sizeLabel == null) {
|
if (sizeLabel == null) {
|
||||||
sizeLabel = new JLabel("N/A");
|
sizeLabel = new JLabel(IconLoader.Size.getIcon());
|
||||||
sizeLabel.setToolTipText("Selection Size");
|
sizeLabel.setFocusable(true);
|
||||||
sizeLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(
|
sizeLabel.setToolTipText("Click to calculate selection size");
|
||||||
0, 1, 0, 1, UIManager.getColor("Separator.shadow")), BorderFactory
|
sizeLabel.addMouseListener(new MouseAdapter() {
|
||||||
.createEmptyBorder(0, 4, 0, 4)));
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
Point2D size = plugInPort.calculateSelectionDimension();
|
||||||
|
boolean metric = ConfigurationManager.getInstance().readBoolean(
|
||||||
|
Presenter.METRIC_KEY, true);
|
||||||
|
String text;
|
||||||
|
if (size == null) {
|
||||||
|
text = "Selection is empty.";
|
||||||
|
} else {
|
||||||
|
text = "Selection size: " + sizeFormat.format(size.getX()) + " x "
|
||||||
|
+ sizeFormat.format(size.getY()) + (metric ? " cm" : " in");
|
||||||
|
}
|
||||||
|
JOptionPane.showMessageDialog(SwingUtilities.getRootPane(StatusBar.this), text,
|
||||||
|
"Information", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return sizeLabel;
|
return sizeLabel;
|
||||||
}
|
}
|
||||||
@@ -151,10 +169,10 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
gbc.weightx = 0;
|
gbc.weightx = 0;
|
||||||
add(getSizeLabel(), gbc);
|
add(zoomPanel, gbc);
|
||||||
|
|
||||||
gbc.gridx = 2;
|
gbc.gridx = 2;
|
||||||
add(zoomPanel, gbc);
|
add(getSizeLabel(), gbc);
|
||||||
|
|
||||||
gbc.gridx = 3;
|
gbc.gridx = 3;
|
||||||
add(getUpdateLabel(), gbc);
|
add(getUpdateLabel(), gbc);
|
||||||
@@ -179,8 +197,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
@Override
|
@Override
|
||||||
public EnumSet<EventType> getSubscribedEventTypes() {
|
public EnumSet<EventType> getSubscribedEventTypes() {
|
||||||
return EnumSet.of(EventType.ZOOM_CHANGED, EventType.SLOT_CHANGED,
|
return EnumSet.of(EventType.ZOOM_CHANGED, EventType.SLOT_CHANGED,
|
||||||
EventType.AVAILABLE_CTRL_POINTS_CHANGED, EventType.SELECTION_SIZE_CHANGED,
|
EventType.AVAILABLE_CTRL_POINTS_CHANGED, EventType.SELECTION_CHANGED);
|
||||||
EventType.SELECTION_CHANGED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -217,18 +234,6 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
Collections.sort(this.stuckComponentNames);
|
Collections.sort(this.stuckComponentNames);
|
||||||
refreshStatusText();
|
refreshStatusText();
|
||||||
break;
|
break;
|
||||||
case SELECTION_SIZE_CHANGED:
|
|
||||||
Point2D size = (Point2D) params[0];
|
|
||||||
boolean metric = ConfigurationManager.getInstance().readBoolean(Presenter.METRIC_KEY,
|
|
||||||
true);
|
|
||||||
if (size == null) {
|
|
||||||
getSizeLabel().setText("N/A");
|
|
||||||
} else {
|
|
||||||
getSizeLabel().setText(
|
|
||||||
sizeFormat.format(size.getX()) + " x " + sizeFormat.format(size.getY())
|
|
||||||
+ (metric ? " cm" : " in"));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SLOT_CHANGED:
|
case SLOT_CHANGED:
|
||||||
componentSlot = (ComponentType) params[0];
|
componentSlot = (ComponentType) params[0];
|
||||||
controlPointSlot = (Point) params[1];
|
controlPointSlot = (Point) params[1];
|
||||||
|
|||||||
+37
-41
@@ -3,13 +3,6 @@ package org.diylc.swing.plugins.toolbox;
|
|||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Insets;
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.KeyAdapter;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -49,45 +42,48 @@ class ComponentTabbedPane extends JTabbedPane {
|
|||||||
JPanel panel = createTab((componentTypes.get(category)));
|
JPanel panel = createTab((componentTypes.get(category)));
|
||||||
addTab(category, panel);
|
addTab(category, panel);
|
||||||
}
|
}
|
||||||
setPreferredSize(new Dimension(-1, Presenter.ICON_SIZE + ComponentButton.MARGIN * 2 + 38));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JPanel createTab(List<ComponentType> componentTypes) {
|
private JPanel createTab(List<ComponentType> componentTypes) {
|
||||||
JPanel panel = new JPanel(new BorderLayout());
|
JPanel panel = new JPanel(new BorderLayout());
|
||||||
final JScrollPane scrollPane = createComponentScrollBar(componentTypes);
|
// final JScrollPane scrollPane =
|
||||||
|
// createComponentScrollBar(componentTypes);
|
||||||
panel.setOpaque(false);
|
panel.setOpaque(false);
|
||||||
JButton leftButton = new JButton("<");
|
panel.add(createComponentPanel(componentTypes), BorderLayout.CENTER);
|
||||||
leftButton.addActionListener(new ActionListener() {
|
// JButton leftButton = new JButton("<");
|
||||||
|
// leftButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
//
|
||||||
public void actionPerformed(ActionEvent e) {
|
// @Override
|
||||||
Rectangle rect = scrollPane.getVisibleRect();
|
// public void actionPerformed(ActionEvent e) {
|
||||||
if (rect.x > SCROLL_STEP) {
|
// Rectangle rect = scrollPane.getVisibleRect();
|
||||||
rect.translate(-SCROLL_STEP, 0);
|
// if (rect.x > SCROLL_STEP) {
|
||||||
} else {
|
// rect.translate(-SCROLL_STEP, 0);
|
||||||
rect.translate(-rect.x, 0);
|
// } else {
|
||||||
}
|
// rect.translate(-rect.x, 0);
|
||||||
}
|
// }
|
||||||
});
|
// }
|
||||||
leftButton.setMargin(new Insets(0, 2, 0, 2));
|
// });
|
||||||
JButton rightButton = new JButton(">");
|
// leftButton.setMargin(new Insets(0, 2, 0, 2));
|
||||||
rightButton.addActionListener(new ActionListener() {
|
// JButton rightButton = new JButton(">");
|
||||||
|
// rightButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
//
|
||||||
public void actionPerformed(ActionEvent e) {
|
// @Override
|
||||||
Rectangle rect = scrollPane.getVisibleRect();
|
// public void actionPerformed(ActionEvent e) {
|
||||||
if (rect.x + rect.width < scrollPane.getViewport().getSize().width - SCROLL_STEP) {
|
// Rectangle rect = scrollPane.getVisibleRect();
|
||||||
rect.translate(SCROLL_STEP, 0);
|
// if (rect.x + rect.width < scrollPane.getViewport().getSize().width -
|
||||||
} else {
|
// SCROLL_STEP) {
|
||||||
rect.translate(scrollPane.getViewport().getSize().width - rect.x - rect.width,
|
// rect.translate(SCROLL_STEP, 0);
|
||||||
0);
|
// } else {
|
||||||
}
|
// rect.translate(scrollPane.getViewport().getSize().width - rect.x -
|
||||||
}
|
// rect.width,
|
||||||
});
|
// 0);
|
||||||
rightButton.setMargin(new Insets(0, 2, 0, 2));
|
// }
|
||||||
panel.add(leftButton, BorderLayout.WEST);
|
// }
|
||||||
panel.add(scrollPane);
|
// });
|
||||||
panel.add(rightButton, BorderLayout.EAST);
|
// rightButton.setMargin(new Insets(0, 2, 0, 2));
|
||||||
|
// panel.add(leftButton, BorderLayout.WEST);
|
||||||
|
// panel.add(scrollPane);
|
||||||
|
// panel.add(rightButton, BorderLayout.EAST);
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user