Merge pull request #198 from kruland2607/override-indicators
Override indicators
This commit is contained in:
commit
4d4acee6de
@ -1127,7 +1127,8 @@ TCMotorSelPan.btn.close = Close
|
|||||||
PlotDialog.CheckBox.Showdatapoints = Show data points
|
PlotDialog.CheckBox.Showdatapoints = Show data points
|
||||||
PlotDialog.lbl.Chart = left click drag to zoom area. mouse wheel to zoom. ctrl-mouse wheel to zoom x axis only. ctrl-left click drag to pan. right click drag to zoom dynamically.
|
PlotDialog.lbl.Chart = left click drag to zoom area. mouse wheel to zoom. ctrl-mouse wheel to zoom x axis only. ctrl-left click drag to pan. right click drag to zoom dynamically.
|
||||||
|
|
||||||
|
ComponentTree.ttip.massoverride = mass override
|
||||||
|
ComponentTree.ttip.cgoverride = cg override
|
||||||
! "main" prefix is used for the main application dialog
|
! "main" prefix is used for the main application dialog
|
||||||
|
|
||||||
# FIXME: Rename the description keys
|
# FIXME: Rename the description keys
|
||||||
|
BIN
core/resources/pix/icons/cg-override.png
Normal file
BIN
core/resources/pix/icons/cg-override.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 345 B |
BIN
core/resources/pix/icons/mass-override.png
Executable file
BIN
core/resources/pix/icons/mass-override.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 545 B |
@ -3,17 +3,26 @@ package net.sf.openrocket.gui.main.componenttree;
|
|||||||
|
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTree;
|
import javax.swing.JTree;
|
||||||
|
import javax.swing.UIManager;
|
||||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.main.ComponentIcons;
|
import net.sf.openrocket.gui.main.ComponentIcons;
|
||||||
|
import net.sf.openrocket.gui.util.Icons;
|
||||||
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.unit.UnitGroup;
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
import net.sf.openrocket.util.TextUtil;
|
import net.sf.openrocket.util.TextUtil;
|
||||||
|
|
||||||
public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
|
public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
|
||||||
|
|
||||||
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getTreeCellRendererComponent(
|
public Component getTreeCellRendererComponent(
|
||||||
JTree tree,
|
JTree tree,
|
||||||
@ -24,28 +33,53 @@ public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
|
|||||||
int row,
|
int row,
|
||||||
boolean hasFocus1) {
|
boolean hasFocus1) {
|
||||||
|
|
||||||
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus1);
|
Component comp = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus1);
|
||||||
|
|
||||||
// Set icon
|
// Set icon
|
||||||
setIcon(ComponentIcons.getSmallIcon(value.getClass()));
|
setIcon(ComponentIcons.getSmallIcon(value.getClass()));
|
||||||
|
|
||||||
// Set tooltip
|
|
||||||
RocketComponent c = (RocketComponent) value;
|
RocketComponent c = (RocketComponent) value;
|
||||||
|
|
||||||
|
if ( c.isMassOverridden() || c.isCGOverridden()) {
|
||||||
|
JPanel p = new JPanel();
|
||||||
|
p.setLayout( new FlowLayout( FlowLayout.LEFT, 1,1) );
|
||||||
|
p.setBackground( UIManager.getColor("Tree.textBackground"));
|
||||||
|
p.setForeground( UIManager.getColor("Tree.textForeground"));
|
||||||
|
p.add(comp/*, BorderLayout.WEST*/);
|
||||||
|
if ( c.isMassOverridden() ) {
|
||||||
|
p.add( new JLabel( Icons.MASS_OVERRIDE ) );
|
||||||
|
}
|
||||||
|
if ( c.isCGOverridden() ) {
|
||||||
|
p.add( new JLabel(Icons.CG_OVERRIDE) );
|
||||||
|
}
|
||||||
|
p.setToolTipText(getToolTip(c));
|
||||||
|
comp = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set tooltip
|
||||||
this.setToolTipText(getToolTip(c));
|
this.setToolTipText(getToolTip(c));
|
||||||
|
|
||||||
return this;
|
return comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getToolTip(RocketComponent c) {
|
private static String getToolTip(RocketComponent c) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("<html>");
|
sb.append("<html>");
|
||||||
|
|
||||||
sb.append("<b>").append(c.getName()).append("</b>");
|
sb.append("<b>").append(c.getName()).append("</b>");
|
||||||
if (c.isMassive()) {
|
if (c.isMassive() || c.isMassOverridden() ) {
|
||||||
sb.append(" (").append(UnitGroup.UNITS_MASS.toStringUnit(c.getMass())).append(")");
|
sb.append(" (").append(UnitGroup.UNITS_MASS.toStringUnit(c.getMass())).append(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( c.isMassOverridden() ) {
|
||||||
|
sb.append(" ").append(trans.get("ComponentTree.ttip.massoverride"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( c.isCGOverridden() ) {
|
||||||
|
sb.append(" ").append(trans.get("ComponentTree.ttip.cgoverride"));
|
||||||
|
}
|
||||||
|
|
||||||
String comment = c.getComment().trim();
|
String comment = c.getComment().trim();
|
||||||
if (comment.length() > 0) {
|
if (comment.length() > 0) {
|
||||||
comment = TextUtil.escapeXML(comment);
|
comment = TextUtil.escapeXML(comment);
|
||||||
|
@ -83,6 +83,9 @@ public class Icons {
|
|||||||
public static final Icon NOT_FAVORITE = loadImageIcon("pix/icons/star_silver.png", "Not favorite");
|
public static final Icon NOT_FAVORITE = loadImageIcon("pix/icons/star_silver.png", "Not favorite");
|
||||||
public static final Icon FAVORITE = loadImageIcon("pix/icons/star_gold.png", "Favorite");
|
public static final Icon FAVORITE = loadImageIcon("pix/icons/star_gold.png", "Favorite");
|
||||||
|
|
||||||
|
public static final Icon CG_OVERRIDE = loadImageIcon("pix/icons/cg-override.png", "CG Override");
|
||||||
|
public static final Icon MASS_OVERRIDE = loadImageIcon("pix/icons/mass-override.png", "Mass Override");
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
log.debug("Icons loaded");
|
log.debug("Icons loaded");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user