本文整理汇总了Java中VASSAL.build.module.map.boardPicker.board.mapgrid.Zone类的典型用法代码示例。如果您正苦于以下问题:Java Zone类的具体用法?Java Zone怎么用?Java Zone使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Zone类属于VASSAL.build.module.map.boardPicker.board.mapgrid包,在下文中一共展示了Zone类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLocation
import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; //导入依赖的package包/类
public Point getLocation(String location) throws BadCoords {
for (Zone zone : zones) {
try {
Point p = zone.getLocation(location);
if (p != null && zone.contains(p)) {
return p;
}
}
catch (BadCoords bc) {
}
}
if (background != null)
return background.getLocation(location);
else
throw new BadCoords();
}
示例2: getGridShape
import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; //导入依赖的package包/类
public Area getGridShape(Point center, int range) {
Area a = null;
Zone z = findZone(center);
if (z != null
&& z.getGrid() instanceof GeometricGrid) {
a = ((GeometricGrid)z.getGrid()).getGridShape(center,range);
}
if (a == null
&& background instanceof GeometricGrid) {
a = ((GeometricGrid)background).getGridShape(center,range);
}
if (a == null) {
a = new Area(new Ellipse2D.Double(center.x-range, center.y-range, range * 2, range * 2));
}
return a;
}
示例3: setOldProperties
import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; //导入依赖的package包/类
/**
* Set the Oldxxxx properties related to movement
* @param p
*/
public static void setOldProperties(GamePiece p) {
String mapName = ""; //$NON-NLS-1$
String boardName = ""; //$NON-NLS-1$
String zoneName = ""; //$NON-NLS-1$
String locationName = ""; //$NON-NLS-1$
final Map m = p.getMap();
final Point pos = p.getPosition();
if (m != null) {
mapName = m.getConfigureName();
final Board b = m.findBoard(pos);
if (b != null) {
boardName = b.getName();
}
final Zone z = m.findZone(pos);
if (z != null) {
zoneName = z.getName();
}
locationName = m.locationName(pos);
}
p.setProperty(BasicPiece.OLD_X, String.valueOf(pos.x));
p.setProperty(BasicPiece.OLD_Y, String.valueOf(pos.y));
p.setProperty(BasicPiece.OLD_MAP, mapName);
p.setProperty(BasicPiece.OLD_BOARD, boardName);
p.setProperty(BasicPiece.OLD_ZONE, zoneName);
p.setProperty(BasicPiece.OLD_LOCATION_NAME, locationName);
}
示例4: draw
import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; //导入依赖的package包/类
public void draw(java.awt.Graphics g, Map m) {
if (initializing || !visible) {
return;
}
g.setColor(threadColor);
Point mapAnchor = map.componentCoordinates(anchor);
Point mapArrow = map.componentCoordinates(arrow);
g.drawLine(mapAnchor.x, mapAnchor.y, mapArrow.x, mapArrow.y);
Board b;
if (drawRange) {
if (rangeScale > 0) {
int dist = (int)(rangeRounding + anchor.getLocation().distance(arrow.getLocation())/rangeScale);
drawRange(g, dist);
}
else {
b = map.findBoard(anchor);
MapGrid grid = null;
if (b != null) {
grid = b.getGrid();
}
if (grid != null && grid instanceof ZonedGrid) {
Point bp = new Point(anchor);
bp.translate(-b.bounds().x, -b.bounds().y);
Zone z = ((ZonedGrid) b.getGrid()).findZone(bp);
if (z != null) {
grid = z.getGrid();
}
}
if (grid != null) {
drawRange(g, grid.range(anchor, arrow));
}
}
}
lastAnchor = mapAnchor;
lastArrow = mapArrow;
}
示例5: locationName
import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; //导入依赖的package包/类
public String locationName(Point p) {
String name = null;
for (Zone zone : zones) {
if (zone.contains(p)) {
name = zone.locationName(p);
break;
}
}
if (name == null
&& background != null) {
name = background.locationName(p);
}
return name;
}
示例6: localizedLocationName
import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; //导入依赖的package包/类
public String localizedLocationName(Point p) {
String name = null;
for (Zone zone : zones) {
if (zone.contains(p)) {
name = zone.localizedLocationName(p);
break;
}
}
if (name == null
&& background != null) {
name = background.localizedLocationName(p);
}
return name;
}
示例7: range
import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; //导入依赖的package包/类
public int range(Point p1, Point p2) {
MapGrid grid = background;
Zone z1 = findZone(p1);
Zone z2 = findZone(p2);
if (z1 == z2
&& z1 != null
&& z1.getGrid() != null) {
grid = z1.getGrid();
}
return grid != null ? grid.range(p1, p2) : (int)Math.round(p1.distance(p2));
}
示例8: findZone
import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; //导入依赖的package包/类
public Zone findZone(Point p) {
for (Zone zone : zones) {
if (zone.contains(p)) {
return zone;
}
}
return null;
}
示例9: snapTo
import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; //导入依赖的package包/类
public Point snapTo(Point p) {
Point snap = null;
Zone z = findZone(p);
if (z != null) {
snap = z.snapTo(p);
}
if (snap == null) {
snap = background != null ? background.snapTo(p) : p;
}
return snap;
}
示例10: isLocationRestricted
import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; //导入依赖的package包/类
public boolean isLocationRestricted(Point p) {
for (Zone zone : zones) {
if (zone.contains(p)) {
return zone.getGrid() != null && zone.getGrid().isLocationRestricted(p);
}
}
return background != null && background.isLocationRestricted(p);
}
示例11: findZone
import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; //导入依赖的package包/类
/**
*
* @return the {@link Zone} on this map containing the argument point
*/
public Zone findZone(Point p) {
Board b = findBoard(p);
if (b != null) {
MapGrid grid = b.getGrid();
if (grid != null && grid instanceof ZonedGrid) {
Rectangle r = b.bounds();
p.translate(-r.x, -r.y); // Translate to Board co-ords
return ((ZonedGrid) grid).findZone(p);
}
}
return null;
}
示例12: addTo
import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; //导入依赖的package包/类
public void addTo(Buildable parent) {
property.addTo((MutablePropertiesContainer) parent);
GameModule.getGameModule().addCommandEncoder(this);
GameModule.getGameModule().getGameState().addGameComponent(this);
propertySource = (PropertySource) parent;
parentZone = (Zone) parent;
}
示例13: ZoneIndex
import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; //导入依赖的package包/类
public ZoneIndex(String name, Zone zone) {
this.name = name;
this.zone = zone;
pieces = new ArrayList<ZonePiece>();
this.map = "";
if (zone.getMap() != null)
this.map = zone.getMap().getMapName();
this.offsetX = zone.getBoard().bounds().x;
this.offsetY = zone.getBoard().bounds().y;
}
示例14: myKeyEvent
import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; //导入依赖的package包/类
public Command myKeyEvent(KeyStroke stroke) {
Command comm = new NullCommand();
for (int i = 0; i < keyCommands.length; i++) {
if (keyCommands[i].matches(stroke)) {
MutableProperty prop = null;
String propertyName = (new FormattedString(key)).getText(Decorator.getOutermost(this));
ArrayList<MutablePropertiesContainer> propertyContainers =
new ArrayList<MutablePropertiesContainer>();
propertyContainers.add(0, GameModule.getGameModule());
Map map = getMap();
if (NAMED_MAP.equals(propertyLevel)) {
String mapName = (new FormattedString(searchName)).getText(Decorator.getOutermost(this));
map = Map.getMapById(mapName);
}
if (map != null) {
propertyContainers.add(0, map);
}
Zone z = null;
if (CURRENT_ZONE.equals(propertyLevel) && getMap() != null) {
z = getMap().findZone(getPosition());
}
else if (NAMED_ZONE.equals(propertyLevel) && getMap() != null) {
String zoneName = (new FormattedString(searchName)).getText(Decorator.getOutermost(this));
z = getMap().findZone(zoneName);
}
if (z != null) {
propertyContainers.add(0, z);
}
prop = MutableProperty.Util.findMutableProperty(propertyName, propertyContainers);
/*
* Debugging could be painful, so print a useful message in the
* Chat Window if no property can be found to update
*/
if (prop == null) {
String s = "Set Global Property (" + description + "): Unable to locate Global Property named " + propertyName;
if (!propertyLevel.equals(CURRENT_ZONE)) {
s += " in " + propertyLevel + " " + searchName;
}
GameModule.getGameModule().warn(s);
}
else {
String oldValue = prop.getPropertyValue();
String newValue = keyCommands[i].propChanger.getNewValue(oldValue);
format.setFormat(newValue);
newValue = format.getText(Decorator.getOutermost(this));
comm = prop.setPropertyValue(newValue);
}
}
}
return comm;
}
示例15: getPublicProperty
import VASSAL.build.module.map.boardPicker.board.mapgrid.Zone; //导入依赖的package包/类
public Object getPublicProperty(Object key) {
if (Properties.KEY_COMMANDS.equals(key)) {
return getKeyCommands();
}
else if (LOCATION_NAME.equals(key)) {
return getMap() == null ? "" : getMap().locationName(getPosition());
}
else if (PIECE_NAME.equals(key)) {
return Decorator.getOutermost(this).getName();
}
else if (CURRENT_MAP.equals(key)) {
return getMap() == null ? "" : getMap().getConfigureName();
}
else if (DECK_NAME.equals(key)) {
return getParent() instanceof Deck ? ((Deck) getParent()).getDeckName() : "";
}
else if (DECK_POSITION.equals(key)) {
if (getParent() instanceof Deck) {
final Deck deck = (Deck) getParent();
final int size = deck.getPieceCount();
final int pos = deck.indexOf(Decorator.getOutermost(this));
return String.valueOf(size - pos + 1);
}
else {
return "0";
}
}
else if (CURRENT_BOARD.equals(key)) {
if (getMap() != null) {
final Board b = getMap().findBoard(getPosition());
if (b != null) {
return b.getName();
}
}
return "";
}
else if (CURRENT_ZONE.equals(key)) {
if (getMap() != null) {
final Zone z = getMap().findZone(getPosition());
if (z != null) {
return z.getName();
}
}
return "";
}
else if (CURRENT_X.equals(key)) {
return String.valueOf(getPosition().x);
}
else if (CURRENT_Y.equals(key)) {
return String.valueOf(getPosition().y);
}
else if (Properties.VISIBLE_STATE.equals(key)) {
return "";
}
Object prop = props == null ? null : props.get(key);
if (prop == null) {
final Map map = getMap();
final Zone zone = (map == null ? null : map.findZone(getPosition()));
if (zone != null) {
prop = zone.getProperty(key);
}
else if (map != null) {
prop = map.getProperty(key);
}
else {
prop = GameModule.getGameModule().getProperty(key);
}
}
return prop;
}