@SuppressWarnings("rawtypes") private JComponent makeEditor(LibArgument la) { switch (arg.kind) { case Argument.ARG_BOOLEAN: final String[] sab = {"false", "true"}; return new JComboBox(sab); case Argument.ARG_MENU: if (la == null) return new JTextField(arg.getVal()); final String[] sam = la.menu.split("\\|"); // $NON-NLS-1$ return new JComboBox(sam); case Argument.ARG_COLOR: return new ColorSelect(Util.convertGmColor(Integer.parseInt(arg.getVal()))); case Argument.ARG_SPRITE: case Argument.ARG_SOUND: case Argument.ARG_BACKGROUND: case Argument.ARG_PATH: case Argument.ARG_SCRIPT: case Argument.ARG_GMOBJECT: case Argument.ARG_ROOM: case Argument.ARG_FONT: case Argument.ARG_TIMELINE: Resource.Kind rk = Argument.getResourceKind(arg.kind); return new ResourceMenu(rk, getNoSelectionString(rk), 120); default: return new JTextField(arg.getVal()); } }
public BufferedImage getDisplayImage() { if (backgroundImage == null) return null; BufferedImage bi; if (imageCache != null) { bi = imageCache.get(); if (bi != null) { return bi; } } bi = backgroundImage; if (get(PBackground.TRANSPARENT)) bi = Util.getTransparentIcon(bi); imageCache = new SoftReference<BufferedImage>(bi); return bi; }
@SuppressWarnings({"unchecked", "rawtypes"}) public void discard() { if (editor instanceof JTextField) { ((JTextField) editor).setText(arg.getVal()); } else if (editor instanceof JComboBox) { ((JComboBox) editor).setSelectedIndex(Integer.parseInt(arg.getVal())); } else if (editor instanceof ColorSelect) { Color c = Util.convertGmColor(Integer.parseInt(arg.getVal())); ((ColorSelect) editor).setSelectedColor(c); } else if (editor instanceof ResourceMenu) { try { ((ResourceMenu) editor).setSelected(arg.getRes()); } catch (NumberFormatException nfe) { } } }
/** Commits any changes in the Component editor to update this Argument. */ public void commit() { if (editor instanceof JTextField) { arg.setVal(((JTextField) editor).getText()); return; } if (editor instanceof JComboBox) { arg.setVal(Integer.toString(((JComboBox) editor).getSelectedIndex())); return; } if (editor instanceof ColorSelect) { arg.setVal(Integer.toString(Util.getGmColor(((ColorSelect) editor).getSelectedColor()))); } if (editor instanceof ArrowsEditor) { arg.setVal(((ArrowsEditor) editor).getStringValue()); } if (editor instanceof ResourceMenu<?>) { arg.setRes(((ResourceMenu<?>) editor).getSelected()); return; } }
protected void postCopy(Background dest) { dest.backgroundImage = Util.cloneImage(backgroundImage); }