4 import java.awt.Dimension;
5 import java.lang.reflect.*;
20 private int width = 140;
21 private int heightComponent = 30;
23 private boolean autoBuild;
26 this.gAllObjects = gAllObjects;
27 this.autoBuild = autoBuild;
29 setLayout(
new BoxLayout(
this, BoxLayout.Y_AXIS));
30 setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
31 Box.createHorizontalStrut(width);
35 Method methods[] = Indicators.class.getMethods();
38 for (Method method : methods)
40 if (Modifier.isStatic (method.getModifiers()))
42 this.add(
new IndicatorLabel(addSpaces(method.getName()), method.getName(), gAllObjects));
46 methods = Commands.class.getMethods();
48 for (Method method : methods)
50 if (Modifier.isStatic (method.getModifiers()))
52 this.add(
new CommandButton(addSpaces(method.getName()), method.getName(), gAllObjects));
75 this.add(
new CommandButton(
"Select All",
"selectAll", gAllObjects));
76 this.add(
new CommandButton(
"Deselect All",
"deselectAll", gAllObjects));
77 this.add(
new CommandButton(
"Del Last selected",
"delLastSelected",
79 this.add(Box.createVerticalStrut(10));
80 this.add(
new CommandButton(
"Make Line",
"makeLine", gAllObjects));
81 this.add(
new CommandButton(
"Cross Lines",
"crossLines", gAllObjects));
87 public void add(JComponent comp)
89 comp.setPreferredSize(
new Dimension(width, heightComponent));
90 comp.setMaximumSize(
new Dimension(Short.MAX_VALUE, heightComponent));
91 comp.setMinimumSize(
new Dimension(width, heightComponent));
95 private String addSpaces(String text)
97 StringBuffer res =
new StringBuffer(
"");
98 res.append(Character.toUpperCase(text.charAt(0)));
99 for (
int i = 1; i < text.length(); i++)
101 char c = text.charAt(i);
102 if (Character.isUpperCase(c))
108 return new String(res);
Kласс для хранения графических объектов
Панель управляющих виджетов (кнопок вызавающих команды и индикаторов). Виждеты добавляются в конструк...
void add(JComponent comp)
добавляет на панель управляющий виджет
CommandBox(GeomContainer gAllObjects, boolean autoBuild)