本文整理汇总了Java中com.esri.core.map.Graphic类的典型用法代码示例。如果您正苦于以下问题:Java Graphic类的具体用法?Java Graphic怎么用?Java Graphic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Graphic类属于com.esri.core.map包,在下文中一共展示了Graphic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import com.esri.core.map.Graphic; //导入依赖的package包/类
private void add(List<Cluster<ClusterableLocation>> clusters) {
int max = getMax(clusters);
for (Cluster<ClusterableLocation> cluster : clusters) {
Geometry geometry = null;
Symbol symbol = null;
Color color = cluster.getPoints().size() == max ? Color.RED : Color.GRAY;
ClusterType thisClusterType = cluster.getPoints().size() < 2 ? ClusterType.POINT : clusterType;
switch (thisClusterType) {
default:
case POINT:
geometry = getCenter(cluster);
symbol = createPointSymbol(color, cluster.getPoints().size());
break;
case BOUNDING_RECTANGLE:
geometry = getBoundingRectangle(cluster);
symbol = createPolygonSymbol(color, cluster.getPoints().size());
break;
case CONVEX_HULL:
geometry = getConvexHull(cluster);
symbol = createPolygonSymbol(color, cluster.getPoints().size());
break;
};
addGraphic(new Graphic(geometry, symbol));
}
}
示例2: setIdentifyPoint
import com.esri.core.map.Graphic; //导入依赖的package包/类
/**
* Sets the point that was used for the identify operation, for display purposes.
* Ignored if null.
* @param pt The point that was used for the identify operation, for display
* purposes. Ignored if null.
*/
public void setIdentifyPoint(Point pt) {
identifyPoint = pt;
if (null != pt) {
graphicsLayer.setVisible(true);
if (!isGraphicsLayerAdded) {
mapController.addLayer(Integer.MAX_VALUE, graphicsLayer, false);
isGraphicsLayerAdded = true;
}
String mgrs = mapController.pointToMgrs(pt, mapController.getSpatialReference());
jLabel_mgrs.setText(mgrs);
if (-1 != identifyPointGraphicUid) {
graphicsLayer.updateGraphic(identifyPointGraphicUid, pt);
} else {
identifyPointGraphicUid = graphicsLayer.addGraphic(new Graphic(pt, identifyPointSymbol));
}
}
}
示例3: displaySpotReport
import com.esri.core.map.Graphic; //导入依赖的package包/类
@Override
protected Integer displaySpotReport(double x, double y, final int wkid, Integer graphicId, Geomessage geomessage) {
try {
Geometry pt = new Point(x, y);
if (null != mapController.getSpatialReference() && wkid != mapController.getSpatialReference().getID()) {
pt = GeometryEngine.project(pt, SpatialReference.create(wkid), mapController.getSpatialReference());
}
if (null != graphicId) {
spotReportLayer.updateGraphic(graphicId, pt);
spotReportLayer.updateGraphic(graphicId, geomessage.getProperties());
} else {
Graphic graphic = new Graphic(pt, spotReportSymbol, geomessage.getProperties());
graphicId = spotReportLayer.addGraphic(graphic);
}
return graphicId;
} catch (NumberFormatException nfe) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, "Could not parse spot report", nfe);
return null;
}
}
示例4: removeGeomessage
import com.esri.core.map.Graphic; //导入依赖的package包/类
private void removeGeomessage(Graphic graphic, boolean sendRemoveMessageForOwnMessages) {
final String geomessageId = (String) graphic.getAttributeValue(Geomessage.ID_FIELD_NAME);
final String geomessageType = (String) graphic.getAttributeValue(Geomessage.TYPE_FIELD_NAME);
String uniqueDesignation = (String) graphic.getAttributeValue("uniquedesignation");
if (sendRemoveMessageForOwnMessages && null != uniqueDesignation && uniqueDesignation.equals(messageController.getSenderUsername())) {
new Thread() {
public void run() {
try {
sendRemoveMessage(messageController, geomessageId, geomessageType);
} catch (Throwable t) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, "Couldn't send REMOVE message", t);
}
}
}.start();
} else {
processRemoveGeomessage(geomessageId, geomessageType);
}
}
示例5: mouseClicked
import com.esri.core.map.Graphic; //导入依赖的package包/类
/**
* Computes the drive time zones on click of the mouse.
*/
@Override
public void mouseClicked(MouseEvent mapEvent) {
super.mouseClicked(mapEvent);
if (!enabled) {
return;
}
if (mapEvent.getButton() == MouseEvent.BUTTON3) {
// remove zones from previous computation
graphicsLayer.removeAll();
return;
}
// the click point is the starting point
Point startPoint = jMap.toMapPoint(mapEvent.getX(), mapEvent.getY());
Graphic startPointGraphic = new Graphic(startPoint, SYM_START_POINT);
graphicsLayer.addGraphic(startPointGraphic);
executeDriveTimes(startPointGraphic);
}
示例6: processResult
import com.esri.core.map.Graphic; //导入依赖的package包/类
/**
* Process result from geoprocessing execution.
*
* @param result output of geoprocessing execution.
*/
private void processResult(GPParameter[] result) {
for (GPParameter outputParameter : result) {
if (outputParameter instanceof GPFeatureRecordSetLayer) {
GPFeatureRecordSetLayer gpLayer = (GPFeatureRecordSetLayer) outputParameter;
int zone = 0;
// get all the graphics and add them to the graphics layer.
// there will be one graphic per zone.
for (Graphic graphic : gpLayer.getGraphics()) {
Graphic theGraphic = new Graphic(graphic.getGeometry(), zoneFillSymbols[zone++]);
// add to the graphics layer
graphicsLayer.addGraphic(theGraphic);
}
}
}
}
示例7: highlightGeometry
import com.esri.core.map.Graphic; //导入依赖的package包/类
private void highlightGeometry(Point point) {
if (point == null) {
return;
}
graphicsLayer.removeAll();
graphicsLayer.addGraphic(
new Graphic(point, new SimpleMarkerSymbol(Color.CYAN, 20, SimpleMarkerSymbol.Style.CIRCLE)));
// -----------------------------------------------------------------------------------------
// Zoom to the highlighted graphic
// -----------------------------------------------------------------------------------------
Geometry geometryForZoom = GeometryEngine.buffer(
point,
map.getSpatialReference(),
map.getFullExtent().getWidth() * 0.10,
map.getSpatialReference().getUnit());
map.zoomTo(geometryForZoom);
}
示例8: processResult
import com.esri.core.map.Graphic; //导入依赖的package包/类
/**
* Process result from geoprocessing execution.
*
* @param result output of geoprocessing execution.
*/
private void processResult(GPParameter[] result) {
for (GPParameter outputParameter : result) {
if (outputParameter instanceof GPFeatureRecordSetLayer) {
GPFeatureRecordSetLayer gpLayer = (GPFeatureRecordSetLayer) outputParameter;
int zone = 0;
// get all the graphics and add them to the graphics layer.
// there will be one graphic per zone.
for (Graphic graphic : gpLayer.getGraphics()) {
SpatialReference fromSR = SpatialReference.create(4326);
Geometry g = graphic.getGeometry();
Geometry pg = GeometryEngine.project(g, fromSR, jMap.getSpatialReference());
Graphic theGraphic = new Graphic(pg, zoneFillSymbols[zone++]);
// add to the graphics layer
graphicsLayer.addGraphic(theGraphic);
}
}
}
}
示例9: addGeoJsonFeatures
import com.esri.core.map.Graphic; //导入依赖的package包/类
/**
* Parse GeoJSON file and add the features to a graphics layer.
* @param graphicsLayer layer to which the features should be added.
*/
private void addGeoJsonFeatures(GraphicsLayer graphicsLayer) {
try {
// create an instance of the parser
GeoJsonParser geoJsonParser = new GeoJsonParser();
// provide the symbology for the features
CompositeSymbol symbol = new CompositeSymbol();
symbol.add(new SimpleFillSymbol(new Color(0, 255, 0, 70)));
symbol.add(new SimpleLineSymbol(Color.BLACK, 2));
geoJsonParser.setSymbol(symbol).setOutSpatialReference(map.getSpatialReference());
// parse geojson data
File geoJsonFile = new File(GEOJSON_DATA_FILE);
List<Feature> features = geoJsonParser.parseFeatures(geoJsonFile);
// add parsed features to a layer
for (Feature f : features) {
graphicsLayer.addGraphic(new Graphic(f.getGeometry(), f.getSymbol(), f.getAttributes()));
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
示例10: parseFeatures
import com.esri.core.map.Graphic; //导入依赖的package包/类
private List<Feature> parseFeatures(ArrayNode jsonFeatures) {
List<Feature> features = new LinkedList<Feature>();
for (JsonNode jsonFeature : jsonFeatures) {
String type = jsonFeature.path(FIELD_TYPE).getTextValue();
if (!FIELD_FEATURE.equals(type)) {
continue;
}
Geometry g = parseGeometry(jsonFeature.path(FIELD_GEOMETRY));
if (outSR != null && outSR.getID() != 4326) {
g = GeometryEngine.project(g, inSR, outSR);
}
Map<String, Object> attributes = parseProperties(jsonFeature.path(FIELD_PROPERTIES));
Feature f = new Graphic(g, symbol, attributes);
features.add(f);
}
return features;
}
示例11: addStaticGraphicsBulk
import com.esri.core.map.Graphic; //导入依赖的package包/类
private void addStaticGraphicsBulk(int numberOfGraphicsToAdd) {
double minx = mapExtent.getXMin();
double maxx = mapExtent.getXMax();
double miny= mapExtent.getYMin();
double maxy = mapExtent.getYMax();
Point[] points = new Point[numberOfGraphicsToAdd];
Graphic[] graphics = new Graphic[numberOfGraphicsToAdd];
int i = 0;
while (i < numberOfGraphicsToAdd) {
Point point = new Point((random.nextFloat()*(maxx-minx)) + minx, (random.nextFloat()*(maxy-miny)) + miny);
points[i] = point;
graphics[i] = new Graphic(point, null);
i++;
}
int[] ids = staticGraphicsLayer.addGraphics(graphics);
for (int j = 0; j < numberOfGraphicsToAdd; j++) {
latestStaticPoints.put(Integer.valueOf(ids[j]), points[j]);
}
}
示例12: addGraphics
import com.esri.core.map.Graphic; //导入依赖的package包/类
private void addGraphics(int numberOfGraphicsToAdd) {
double minx = mapExtent.getXMin();
double maxx = mapExtent.getXMax();
double miny= mapExtent.getYMin();
double maxy = mapExtent.getYMax();
int i = 0;
long startTime = System.currentTimeMillis();
while (i < numberOfGraphicsToAdd) {
Point point = new Point((random.nextFloat()*(maxx-minx)) + minx, (random.nextFloat()*(maxy-miny)) + miny);
int id;
if (addWithSymbol) {
id = graphicsLayer.addGraphic(new Graphic(point, symbol));
} else {
id = graphicsLayer.addGraphic(new Graphic(point, null));
}
latestDynamicPoints.put(Integer.valueOf(id), point);
i++;
}
JOptionPane.showMessageDialog(appWindow, "Total time: " + (System.currentTimeMillis() - startTime)/1000.0 + " seconds.");
}
示例13: movePoints
import com.esri.core.map.Graphic; //导入依赖的package包/类
private void movePoints() {
// loop through them all
if (dynamicGraphicsLayer.getGraphicIDs()!=null) {
for (int id : dynamicGraphicsLayer.getGraphicIDs()) {
Point p1 = latestDynamicPoints.get(Integer.valueOf(id));
Point p2 = getPointForSmoothMove(p1.getX(), p1.getY(), id);
if (moveWithReplace) {
dynamicGraphicsLayer.removeGraphic(id);
int newId = dynamicGraphicsLayer.addGraphic(new Graphic(p2, null));
latestDynamicPoints.put(Integer.valueOf(newId), p2);
} else {
dynamicGraphicsLayer.updateGraphic(id, p2);
//dynamicGraphicsLayer.movePointGraphic(id, p2);
latestDynamicPoints.put(Integer.valueOf(id), p2);
}
// dynamicGraphicsLayer.movePointGraphic(id, getRandomPointFrom(p.getX(), p.getY(), spreadOfMove));
}
}
}
示例14: addSimpleMarkerGraphics
import com.esri.core.map.Graphic; //导入依赖的package包/类
/**
* Adds graphics symbolized with SimpleMarkerSymbols.
* @param graphicsLayer
*/
private void addSimpleMarkerGraphics(GraphicsLayer graphicsLayer, Envelope bounds) {
SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(Color.RED, 16, Style.CIRCLE);
double xmin = bounds.getXMin();
double xmax = bounds.getXMax();
double xrand;
double ymin = bounds.getYMin();
double ymax = bounds.getYMax();
double yrand;
for (int i = 0; i < 1000; i++) {
xrand = xmin + (int) (Math.random() * ((xmax - xmin) + 1));
yrand = ymin + (int) (Math.random() * ((ymax - ymin) + 1));
Point point = new Point(xrand, yrand);
graphicsLayer.addGraphic(new Graphic(point, symbol));
}
}
示例15: GetDistAsString
import com.esri.core.map.Graphic; //导入依赖的package包/类
private String GetDistAsString(Graphic g, SpatialReference inputSr, String units)
{
com.esri.core.geometry.Geometry geo = g.getGeometry();
com.esri.core.geometry.Geometry curGeo;
if(!inputSr.equals(srBuffer))
{
curGeo = GeometryEngine.project(geo, inputSr, srBuffer);
}
else
{
curGeo=geo;
}
double tmpDist = GeometryEngine.distance(inGeometry, curGeo, srBuffer);
UnitConverter uc = new UnitConverter();
int inUnitWkid = uc.findWkid(srBuffer.getUnit().getName());
String cn = uc.findConnonicalName(units);
int outUnitWkid = uc.findWkid(cn);
double dist;
if(inUnitWkid!=outUnitWkid)
{
dist = uc.Convert(tmpDist, inUnitWkid, outUnitWkid);
}
else
{
dist=tmpDist;
}
DecimalFormat df = new DecimalFormat("#.00");
return df.format(dist);
}