use of com.scriptographer.adm.ValueItem in project scriptographer by scriptographer.
the class AdmComponentProxy method getValue.
public Object getValue() {
if (item == null)
return component.getDefaultValue();
switch(component.getType()) {
case STRING:
case TEXT:
return ((TextValueItem) item).getText();
case BUTTON:
return ((Button) item).getText();
case NUMBER:
return ((ValueItem) item).getValue();
case SLIDER:
double value = ((ValueItem) item).getValue() / factor;
Double inc = component.getIncrement();
if (inc != null) {
double pre = value;
value = Math.round(value / inc) * inc;
if (pre != value)
((ValueItem) item).setValue((float) (value * factor));
}
return value;
case BOOLEAN:
return ((ToggleItem) item).isChecked();
case LIST:
ListEntry selected = ((PopupList) item).getSelectedEntry();
if (selected != null)
return component.getOption(selected.getIndex());
break;
case COLOR:
return ((ColorButton) item).getColor();
case FONT:
return ((FontPopupList) item).getFontWeight();
}
return null;
}
use of com.scriptographer.adm.ValueItem in project scriptographer by scriptographer.
the class AdmComponentProxy method addToContent.
protected int addToContent(Dialog dialog, LinkedHashMap<String, com.scriptographer.adm.Component> content, int column, int row) {
Item valueItem = createItem(dialog);
String label = component.getLabel();
boolean isRuler = component.getType() == ComponentType.RULER;
boolean hasLabel = !isRuler && label != null && !"".equals(label);
if (hasLabel) {
TextPane labelItem = new TextPane(dialog);
labelItem.setText(label + ":");
// Adjust top margin of label to reflect the native margin
// in the value item.
Item marginItem = valueItem;
// This is only needed for FontPopupList so far.
if (marginItem instanceof ItemGroup)
marginItem = (Item) ((ItemGroup) marginItem).getContent().get(0);
Border margin = marginItem.getVisualMargin();
// Also take into account any margins the component might have set
if (valueItem != marginItem)
margin = margin.add(valueItem.getMargin());
labelItem.setMargin(margin.top + 3, 4, 0, 0);
content.put(column + ", " + row + ", right, top", labelItem);
}
boolean fullSize = component.getFullSize();
String justification = isRuler || component.getFullSize() ? "full, center" : "left, center";
content.put(isRuler || !hasLabel && fullSize ? column + ", " + row + ", " + (column + 1) + ", " + row + ", " + justification : (column + 1) + ", " + row + ", " + justification, valueItem);
return row + 1;
}
Aggregations