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>
|
||||
<entry>
|
||||
<string>metric</string>
|
||||
<boolean>true</boolean>
|
||||
<string>lastPath</string>
|
||||
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop\oldFiles</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>zoom</string>
|
||||
<double>1.0</double>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>lastPath</string>
|
||||
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop</string>
|
||||
<string>metric</string>
|
||||
<boolean>true</boolean>
|
||||
</entry>
|
||||
<entry>
|
||||
<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
|
||||
* 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,
|
||||
/**
|
||||
* 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.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -28,7 +29,7 @@ import com.diyfever.gui.update.VersionNumber;
|
||||
* @see EventType
|
||||
*/
|
||||
public interface IPlugInPort {
|
||||
|
||||
|
||||
public static final String CHECK_BOX_MENU_ITEM = "org.diylc.checkBoxMenuItem";
|
||||
|
||||
/**
|
||||
@@ -302,6 +303,12 @@ public interface IPlugInPort {
|
||||
* Ungroups all selected components.
|
||||
*/
|
||||
void ungroupSelectedComponents();
|
||||
|
||||
|
||||
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(
|
||||
"donate.png"), Bug("bug.png"), IconLarge("icon_large.png"), IconMedium(
|
||||
"icon_medium.png"), IconSmall("icon_small.png"), DocumentEdit("document_edit.png"), EditComponent(
|
||||
"edit_component.png");
|
||||
"edit_component.png"), Size("size.png");
|
||||
|
||||
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) {
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
calculateSelectionDimension());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -841,8 +839,6 @@ public class Presenter implements IPlugInPort {
|
||||
@Override
|
||||
public void setMetric(boolean isMetric) {
|
||||
ConfigurationManager.getInstance().writeValue(Presenter.METRIC_KEY, isMetric);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
calculateSelectionDimension());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -909,12 +905,6 @@ public class Presenter implements IPlugInPort {
|
||||
includeStuckComponents(controlPointMap);
|
||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents,
|
||||
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 selection size expressed in either inches or centimeters, based
|
||||
* on the user preference.
|
||||
*/
|
||||
private Point2D calculateSelectionDimension() {
|
||||
@Override
|
||||
public Point2D calculateSelectionDimension() {
|
||||
if (selectedComponents.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -1041,8 +1028,6 @@ public class Presenter implements IPlugInPort {
|
||||
projectFileManager.notifyFileChange();
|
||||
}
|
||||
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.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.Format;
|
||||
@@ -20,9 +22,9 @@ import java.util.Map;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.common.BadPositionException;
|
||||
@@ -32,9 +34,9 @@ import org.diylc.common.EventType;
|
||||
import org.diylc.common.IPlugIn;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.images.IconLoader;
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
import org.diylc.swing.gui.MainFrame;
|
||||
|
||||
import com.diyfever.gui.MemoryBar;
|
||||
import com.diyfever.gui.miscutils.ConfigurationManager;
|
||||
@@ -45,7 +47,7 @@ import com.diyfever.gui.update.UpdateLabel;
|
||||
public class StatusBar extends JPanel implements IPlugIn {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(StatusBar.class);
|
||||
|
||||
public static String UPDATE_URL = "http://www.diy-fever.com/update.xml";
|
||||
@@ -70,7 +72,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
super();
|
||||
|
||||
setLayout(new GridBagLayout());
|
||||
|
||||
|
||||
try {
|
||||
swingUI.injectGUIComponent(this, SwingUtilities.BOTTOM);
|
||||
} catch (BadPositionException e) {
|
||||
@@ -123,11 +125,27 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
|
||||
public JLabel getSizeLabel() {
|
||||
if (sizeLabel == null) {
|
||||
sizeLabel = new JLabel("N/A");
|
||||
sizeLabel.setToolTipText("Selection Size");
|
||||
sizeLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(
|
||||
0, 1, 0, 1, UIManager.getColor("Separator.shadow")), BorderFactory
|
||||
.createEmptyBorder(0, 4, 0, 4)));
|
||||
sizeLabel = new JLabel(IconLoader.Size.getIcon());
|
||||
sizeLabel.setFocusable(true);
|
||||
sizeLabel.setToolTipText("Click to calculate selection size");
|
||||
sizeLabel.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@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;
|
||||
}
|
||||
@@ -151,10 +169,10 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
gbc.gridx = 1;
|
||||
gbc.fill = GridBagConstraints.BOTH;
|
||||
gbc.weightx = 0;
|
||||
add(getSizeLabel(), gbc);
|
||||
add(zoomPanel, gbc);
|
||||
|
||||
gbc.gridx = 2;
|
||||
add(zoomPanel, gbc);
|
||||
add(getSizeLabel(), gbc);
|
||||
|
||||
gbc.gridx = 3;
|
||||
add(getUpdateLabel(), gbc);
|
||||
@@ -179,8 +197,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
@Override
|
||||
public EnumSet<EventType> getSubscribedEventTypes() {
|
||||
return EnumSet.of(EventType.ZOOM_CHANGED, EventType.SLOT_CHANGED,
|
||||
EventType.AVAILABLE_CTRL_POINTS_CHANGED, EventType.SELECTION_SIZE_CHANGED,
|
||||
EventType.SELECTION_CHANGED);
|
||||
EventType.AVAILABLE_CTRL_POINTS_CHANGED, EventType.SELECTION_CHANGED);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -217,18 +234,6 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
Collections.sort(this.stuckComponentNames);
|
||||
refreshStatusText();
|
||||
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:
|
||||
componentSlot = (ComponentType) params[0];
|
||||
controlPointSlot = (Point) params[1];
|
||||
|
||||
+37
-41
@@ -3,13 +3,6 @@ package org.diylc.swing.plugins.toolbox;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
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.Collections;
|
||||
import java.util.List;
|
||||
@@ -49,45 +42,48 @@ class ComponentTabbedPane extends JTabbedPane {
|
||||
JPanel panel = createTab((componentTypes.get(category)));
|
||||
addTab(category, panel);
|
||||
}
|
||||
setPreferredSize(new Dimension(-1, Presenter.ICON_SIZE + ComponentButton.MARGIN * 2 + 38));
|
||||
}
|
||||
|
||||
private JPanel createTab(List<ComponentType> componentTypes) {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
final JScrollPane scrollPane = createComponentScrollBar(componentTypes);
|
||||
// final JScrollPane scrollPane =
|
||||
// createComponentScrollBar(componentTypes);
|
||||
panel.setOpaque(false);
|
||||
JButton leftButton = new JButton("<");
|
||||
leftButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Rectangle rect = scrollPane.getVisibleRect();
|
||||
if (rect.x > SCROLL_STEP) {
|
||||
rect.translate(-SCROLL_STEP, 0);
|
||||
} else {
|
||||
rect.translate(-rect.x, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
leftButton.setMargin(new Insets(0, 2, 0, 2));
|
||||
JButton rightButton = new JButton(">");
|
||||
rightButton.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Rectangle rect = scrollPane.getVisibleRect();
|
||||
if (rect.x + rect.width < scrollPane.getViewport().getSize().width - SCROLL_STEP) {
|
||||
rect.translate(SCROLL_STEP, 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);
|
||||
panel.add(createComponentPanel(componentTypes), BorderLayout.CENTER);
|
||||
// JButton leftButton = new JButton("<");
|
||||
// leftButton.addActionListener(new ActionListener() {
|
||||
//
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// Rectangle rect = scrollPane.getVisibleRect();
|
||||
// if (rect.x > SCROLL_STEP) {
|
||||
// rect.translate(-SCROLL_STEP, 0);
|
||||
// } else {
|
||||
// rect.translate(-rect.x, 0);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// leftButton.setMargin(new Insets(0, 2, 0, 2));
|
||||
// JButton rightButton = new JButton(">");
|
||||
// rightButton.addActionListener(new ActionListener() {
|
||||
//
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// Rectangle rect = scrollPane.getVisibleRect();
|
||||
// if (rect.x + rect.width < scrollPane.getViewport().getSize().width -
|
||||
// SCROLL_STEP) {
|
||||
// rect.translate(SCROLL_STEP, 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);
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user