本文整理汇总了Java中VASSAL.build.Buildable类的典型用法代码示例。如果您正苦于以下问题:Java Buildable类的具体用法?Java Buildable怎么用?Java Buildable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Buildable类属于VASSAL.build包,在下文中一共展示了Buildable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTo
import VASSAL.build.Buildable; //导入依赖的package包/类
/**
* Expects to be added to a {@link Map}. Adds itself as a {@link
* GameComponent} and a {@link Drawable}component
*/
public void addTo(Buildable b) {
map = (Map) b;
mouseOverViewer = new CounterViewer();
GameModule.getGameModule().getGameState().addGameComponent(this);
GameModule.getGameModule().addKeyStrokeSource(
new KeyStrokeSource(view, JComponent.WHEN_FOCUSED));
map.addDrawComponent(this);
map.getToolBar().add(launch);
if (b instanceof Translatable) {
getI18nData().setOwningComponent((Translatable) b);
}
map.getLayeredPane().add(scroll, JLayeredPane.PALETTE_LAYER);
}
示例2: validate
import VASSAL.build.Buildable; //导入依赖的package包/类
/** Ensures that no other instance of the same class has the same name */
public void validate(Buildable target, ValidationReport report) {
if (target instanceof Identifyable) {
Identifyable iTarget = (Identifyable) target;
if (iTarget.getConfigureName() == null ||
iTarget.getConfigureName().length() == 0) {
report.addWarning("A " +
ConfigureTree.getConfigureName(target.getClass()) +
" has not been given a name");
}
else if (instances.contains(iTarget)) {
Identifyable compare = null;
for (Iterator<Identifyable> i = instances.iterator();
i.hasNext() && compare != iTarget; ) {
compare = i.next();
if (compare != iTarget &&
iTarget.getConfigureName().equals(compare.getConfigureName())) {
report.addWarning("More than one " +
ConfigureTree.getConfigureName(target.getClass())
+ " named " + iTarget.getConfigureName());
break;
}
}
}
}
}
示例3: add
import VASSAL.build.Buildable; //导入依赖的package包/类
public void add(Buildable b) {
super.add(b);
if (b instanceof GamePieceLayout) {
GamePieceLayout def = (GamePieceLayout) b;
definitions.put(def.getConfigureName(), def);
def.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (Configurable.NAME_PROPERTY.equals(evt.getPropertyName())) {
definitions.remove((String) evt.getOldValue());
definitions.put((String) evt.getNewValue(),
(GamePieceLayout) evt.getSource());
}
}
});
}
}
示例4: validate
import VASSAL.build.Buildable; //导入依赖的package包/类
public void validate(Buildable target, ValidationReport report) {
if (possibleBoards.isEmpty()) {
report.addWarning(Resources.getString("BoardPicker.must_define", ConfigureTree.getConfigureName(map))); //$NON-NLS-1$
}
HashSet<String> names = new HashSet<String>();
for (Board b : possibleBoards) {
if (names.contains(b.getName())) {
report.addWarning(Resources.getString("BoardPicker.more_than_one", b.getName(), ConfigureTree.getConfigureName(map))); //$NON-NLS-1$
}
names.add(b.getName());
if (b.getName() == null) {
report.addWarning(Resources.getString("BoardPicker.no_name",ConfigureTree.getConfigureName(map)));
}
b.validate(b, report);
}
}
示例5: validate
import VASSAL.build.Buildable; //导入依赖的package包/类
public void validate(Buildable b, ValidationReport report) {
if (b == target && target.getComponentsOf(childClass).size() > 1) {
report.addWarning(
"No more than one " +
ConfigureTree.getConfigureName(childClass) +
" allowed in " +
ConfigureTree.getConfigureName(target));
}
}
示例6: addTo
import VASSAL.build.Buildable; //导入依赖的package包/类
public void addTo(Buildable b) {
// Support for players changing sides
PlayerRoster.addSideChangeListener(this);
launch.setAlignmentY(0.0F);
GameModule.getGameModule().getToolBar().add(getComponent());
GameModule.getGameModule().getGameState().addGameComponent(this);
frame = new JDialog(GameModule.getGameModule().getFrame());
frame.setTitle(getConfigureName());
String key = "Inventory." + getConfigureName(); //$NON-NLS-1$
GameModule.getGameModule().getPrefs().addOption(new PositionOption(key, frame));
frame.setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
frame.add(initTree());
frame.add(initButtons());
frame.setSize(250, 350);
}
示例7: addTo
import VASSAL.build.Buildable; //导入依赖的package包/类
public void addTo(Buildable parent) {
Map map = (Map) parent;
map.addDrawComponent(this);
map.addLocalMouseListener(this);
GameModule.getGameModule().getGameState().addGameComponent(this);
instances.put(map, this);
validator = new SingleChildInstance(map, getClass());
}
示例8: addTo
import VASSAL.build.Buildable; //导入依赖的package包/类
public void addTo(Buildable b) {
final GameModule g = GameModule.getGameModule();
property.addTo(g);
if (tabName != null && tabName.length() > 0) {
g.getPrefs().addOption(tabName, getPreferenceConfigurer());
}
if (getVariableName().length() > 0) {
updateGlobalProperty(g.getPrefs().getStoredValue(getVariableName()));
}
}
示例9: addTo
import VASSAL.build.Buildable; //导入依赖的package包/类
public void addTo(Buildable b) {
//Create the turn window
turnWindow = new TurnWindow();
turnWindow.pack();
turnWindow.setVisible(false);
launchWidget = new JPanel();
launchWidget.setLayout(new BorderLayout());
launchWidget.setBorder(BorderFactory.createEtchedBorder());
GameModule.getGameModule().getToolBar().add(launchWidget);
launchWidget.setAlignmentY(0.0F);
launchWidget.setVisible(false);
GameModule.getGameModule().getToolBar().add(launch);
launch.setAlignmentY(0.0F);
launch.setEnabled(false);
setDocked(isDocked());
GameModule.getGameModule().addCommandEncoder(this);
GameModule.getGameModule().getGameState().addGameComponent(this);
idMgr.add(this);
//Global Property support
lastCommand.addTo((MutablePropertiesContainer) b);
lastTurn.addTo((MutablePropertiesContainer) b);
}
示例10: build
import VASSAL.build.Buildable; //导入依赖的package包/类
public void build(org.w3c.dom.Element el) {
validator = new ValidityChecker() {
public void validate(Buildable target, ValidationReport report) {
if (!PlayerRoster.isActive()) {
report.addWarning(Resources.getString("Editor.PrivateMap.warning",
ConfigureTree.getConfigureName(PlayerRoster.class),
ConfigureTree.getConfigureName(getClass())));
}
}
};
surrogate = null;
super.build(el);
}
示例11: addTo
import VASSAL.build.Buildable; //导入依赖的package包/类
public void addTo(Buildable parent) {
if (parent instanceof ToolBarComponent) {
toolbar = ((ToolBarComponent) parent).getToolBar();
}
toolbar.add(launch);
toolbar.addContainerListener(this);
scheduleBuildMenu();
}
示例12: remove
import VASSAL.build.Buildable; //导入依赖的package包/类
public void remove(Buildable b) {
if (b instanceof Widget) {
final Widget w = (Widget) b;
if (tab != null) {
tab.removeChangeListener(this); // prevent bad recursion
tab.removeTabAt(widgets.indexOf(w));
w.removePropertyChangeListener(this);
tab.addChangeListener(this); // restore listener
}
widgets.remove(w);
}
super.remove(b);
}
示例13: addTo
import VASSAL.build.Buildable; //导入依赖的package包/类
/**
* Expects to be added to a GameModule. Adds the button to the
* control window's toolbar and registers itself as a {@link
* KeyStrokeListener} */
public void addTo(Buildable parent) {
ran = GameModule.getGameModule().getRNG();
GameModule.getGameModule().getToolBar().add(getComponent());
property.setPropertyValue("1"); // Initialize with a numeric value //$NON-NLS-1$
property.addTo((MutablePropertiesContainer)parent);
}
示例14: build
import VASSAL.build.Buildable; //导入依赖的package包/类
public void build(Element e) {
if (e == null) return;
final NamedNodeMap nnm = e.getAttributes();
for (int i = 0; i < nnm.getLength(); ++i) {
final Attr att = (Attr) nnm.item(i);
setAttribute(att.getName(), att.getValue());
}
for (Node n = e.getFirstChild(); n != null; n = n.getNextSibling()) {
if (n.getNodeType() == Node.ELEMENT_NODE) {
final Element element = (Element) n;
if ("option".equals(element.getTagName())) { //$NON-NLS-1$
final String optionName = element.getAttribute("name"); //$NON-NLS-1$
final String value = Builder.getText(element);
optionInitialValues.put(optionName, value);
// Update the Configurer value if it is already registered
final Configurer config = optionConfigurers.get(optionName);
if (config != null) {
config.setValue(value);
}
}
else {
try {
final Buildable b = Builder.create(element);
b.addTo(this);
add(b);
}
catch (IllegalBuildException ex) {
ErrorDialog.bug(ex);
}
}
}
}
}
示例15: removeFrom
import VASSAL.build.Buildable; //导入依赖的package包/类
public void removeFrom(Buildable parent) {
if (mainWindowDock == null && root != null && root.getTopLevelAncestor() != null) {
root.getTopLevelAncestor().setVisible(false);
}
GameModule.getGameModule().getToolBar().remove(launch);
idMgr.remove(this);
}