Search in sources :

Example 41 with Point

use of com.forstudy.efjava.ch03.item10.Point in project java-docs-samples by GoogleCloudPlatform.

the class QuickstartSample method main.

public static void main(String... args) throws Exception {
    // Your Google Cloud Platform project ID
    String projectId = System.getProperty("projectId");
    if (projectId == null) {
        System.err.println("Usage: QuickstartSample -DprojectId=YOUR_PROJECT_ID");
        return;
    }
    // Instantiates a client
    MetricServiceClient metricServiceClient = MetricServiceClient.create();
    // Prepares an individual data point
    TimeInterval interval = TimeInterval.newBuilder().setEndTime(Timestamps.fromMillis(System.currentTimeMillis())).build();
    TypedValue value = TypedValue.newBuilder().setDoubleValue(3.14).build();
    Point point = Point.newBuilder().setInterval(interval).setValue(value).build();
    List<Point> pointList = new ArrayList<>();
    pointList.add(point);
    ProjectName name = ProjectName.of(projectId);
    // Prepares the metric descriptor
    Map<String, String> metricLabels = new HashMap<String, String>();
    metricLabels.put("store_id", "Pittsburg");
    Metric metric = Metric.newBuilder().setType("custom.googleapis.com/my_metric").putAllLabels(metricLabels).build();
    // Prepares the monitored resource descriptor
    Map<String, String> resourceLabels = new HashMap<String, String>();
    resourceLabels.put("instance_id", "1234567890123456789");
    resourceLabels.put("zone", "us-central1-f");
    MonitoredResource resource = MonitoredResource.newBuilder().setType("gce_instance").putAllLabels(resourceLabels).build();
    // Prepares the time series request
    TimeSeries timeSeries = TimeSeries.newBuilder().setMetric(metric).setResource(resource).addAllPoints(pointList).build();
    List<TimeSeries> timeSeriesList = new ArrayList<>();
    timeSeriesList.add(timeSeries);
    CreateTimeSeriesRequest request = CreateTimeSeriesRequest.newBuilder().setName(name.toString()).addAllTimeSeries(timeSeriesList).build();
    // Writes time series data
    metricServiceClient.createTimeSeries(request);
    System.out.printf("Done writing time series data.%n");
    metricServiceClient.close();
}
Also used : TimeSeries(com.google.monitoring.v3.TimeSeries) MetricServiceClient(com.google.cloud.monitoring.v3.MetricServiceClient) TimeInterval(com.google.monitoring.v3.TimeInterval) ProjectName(com.google.monitoring.v3.ProjectName) HashMap(java.util.HashMap) CreateTimeSeriesRequest(com.google.monitoring.v3.CreateTimeSeriesRequest) ArrayList(java.util.ArrayList) MonitoredResource(com.google.api.MonitoredResource) Point(com.google.monitoring.v3.Point) Metric(com.google.api.Metric) TypedValue(com.google.monitoring.v3.TypedValue)

Example 42 with Point

use of com.forstudy.efjava.ch03.item10.Point in project CoreJava by alekseiiagnenkov.

the class Lab12 method main.

public static void main(String[] args) {
    Point point = new Point(0, 1);
    long time = System.currentTimeMillis();
    for (int i = 0; i < 100000; i++) {
        point.getX();
    }
    System.out.println("Time:" + (System.currentTimeMillis() - time));
    try {
        long timeRef = System.currentTimeMillis();
        for (int i = 0; i < 100000; i++) {
            point.getClass().getMethod("getX").invoke(point);
        }
        System.out.println("TimeRef:" + (System.currentTimeMillis() - timeRef));
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}
Also used : Point(corejava.chapter4.lab1_2_3.Point) Point(corejava.chapter4.lab1_2_3.Point)

Example 43 with Point

use of com.forstudy.efjava.ch03.item10.Point in project CoreJava by alekseiiagnenkov.

the class Lab9 method main.

public static void main(String[] args) {
    Point point = new Point(0, 0);
    Shape circle = new Circle(new Point(0, 0), 20);
    Queue<Integer> queue = new Queue<>();
    queue.add(1);
    queue.add(2);
    queue.add(3);
    Queue.Iterator iterator = queue.iterator();
    Integer a = 0;
    Character[] strings = { '1', '2', '3' };
    Object[] objects = { strings, 0, a, point, queue, iterator, circle, staticPoint };
    for (Object obj : objects) {
        System.out.println(toString(obj));
    }
}
Also used : Circle(corejava.chapter4.lab4_5.shape.Circle) Shape(corejava.chapter4.lab4_5.shape.Shape) Point(corejava.chapter4.lab1_2_3.Point) Queue(corejava.chapter2.lab16_17.Queue)

Example 44 with Point

use of com.forstudy.efjava.ch03.item10.Point in project cg by nmahoude.

the class Simulation method simulate.

/**
 * simulate the move of any player (dir1, dir2 not null)
 *
 * Pre-requisite : the move is valid only one player will move
 *
 * GameState is backedup
 *
 * @return true if the move is valid
 */
public void simulate(Move move, GameState state) {
    this.move = move;
    this.state = state;
    this.agent = state.agents[move.id];
    Point target = agent.position.get(move.dir1);
    int targetX = agent.x + move.dir1.dx;
    int targetY = agent.y + move.dir1.dy;
    if (!state.isValid(targetX, targetY)) {
        move.dir1Invalid();
        return;
    }
    int occupiedBy = state.occupiedBy(targetX, targetY);
    if (occupiedBy == -1) {
        move.isPush = false;
        computeMove();
        return;
    } else {
        // potential push
        if (state.isFriendly(move.id, targetX, targetY)) {
            move.dir1Invalid();
            return;
        }
        move.isPush = true;
        computePush();
        return;
    }
}
Also used : Point(ww2.Point) Point(ww2.Point)

Example 45 with Point

use of com.forstudy.efjava.ch03.item10.Point in project ddf by codice.

the class KmlToJtsGeometryConverterTest method testConvertPointGeometry.

@Test
public void testConvertPointGeometry() {
    InputStream stream = KmlToJtsGeometryConverterTest.class.getResourceAsStream("/kmlPoint.kml");
    Kml kml = Kml.unmarshal(stream);
    assertThat(kml, notNullValue());
    Point kmlPoint = ((Point) ((Placemark) kml.getFeature()).getGeometry());
    assertThat(kmlPoint, notNullValue());
    org.locationtech.jts.geom.Geometry jtsGeometryPoint = KmlToJtsGeometryConverter.from(kmlPoint);
    assertThat(jtsGeometryPoint, instanceOf(org.locationtech.jts.geom.Point.class));
    assertSpecificGeometry(kmlPoint, jtsGeometryPoint);
}
Also used : Placemark(de.micromata.opengis.kml.v_2_2_0.Placemark) InputStream(java.io.InputStream) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) Point(de.micromata.opengis.kml.v_2_2_0.Point) Test(org.junit.Test)

Aggregations

Point (net.imglib2.Point)33 ArrayList (java.util.ArrayList)16 FloatType (net.imglib2.type.numeric.real.FloatType)11 Test (org.junit.Test)9 List (java.util.List)8 Point (com.google.monitoring.v3.Point)7 Point (hr.fer.oop.recap2.task2.Point)7 FinalInterval (net.imglib2.FinalInterval)7 RealPoint (net.imglib2.RealPoint)7 TimeSeries (com.google.monitoring.v3.TimeSeries)6 Point (de.micromata.opengis.kml.v_2_2_0.Point)6 Interval (net.imglib2.Interval)6 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)6 HyperSphere (net.imglib2.algorithm.region.hypersphere.HyperSphere)6 AffineTransform3D (net.imglib2.realtransform.AffineTransform3D)6 HashMap (java.util.HashMap)5 Metric (com.google.api.Metric)4 TimeInterval (com.google.monitoring.v3.TimeInterval)4 TypedValue (com.google.monitoring.v3.TypedValue)4 Map (java.util.Map)4