Example usage for javax.swing JProgressBar getValue

List of usage examples for javax.swing JProgressBar getValue

Introduction

In this page you can find the example usage for javax.swing JProgressBar getValue.

Prototype

public int getValue() 

Source Link

Document

Returns the progress bar's current value from the BoundedRangeModel.

Usage

From source file:org.gofleet.module.routing.RoutingMap.java

private void processTSPPlan(TSPPlan[] res, JProgressBar progressBar) {
    Random random = new Random();
    try {/*from  w  w w  . j  a v  a 2s .  c o  m*/

        @SuppressWarnings("unchecked")
        Collection<Layer> allLayers = Collections.unmodifiableCollection(this.mapView.getAllLayers());
        List<Layer> toremove = new LinkedList<Layer>();
        for (Layer l : allLayers) {
            if (l.name.startsWith("Route Plan") || l.name.startsWith("Stops"))
                toremove.add(l);
        }
        for (Layer l : toremove)
            this.mapView.removeLayer(l);

        LatLon latlon_origin = null;
        int id_layer = 0;
        for (TSPPlan plan : res) {
            latlon_origin = new LatLon(plan.getOrigin()[1], plan.getOrigin()[0]);
            log.info(latlon_origin);
            LineElemStyle ls = new LineElemStyle();
            float f = random.nextFloat();
            ls.color = Color.getHSBColor(f * random.nextFloat(), 0.9f, 0.9f);
            ls.width = LogicConstants.getInt("PLAN_WAY_WIDTH", 2);
            MarkerLayer stops = new MarkerLayer(new GpxData(), "Stops " + id_layer,
                    File.createTempFile("stops", "tmp"), new GpxLayer(new GpxData()), this.mapView);
            stops.data.add(new StopMarker(latlon_origin, "origin", "tsp_stop", stops, 0, 0, ls.color));
            for (String stop : plan.getStops()) {
                String[] array = stop.split(",");
                double[] point = new double[2];
                point[1] = new Double(array[0]);
                point[0] = new Double(array[1]);

                LatLon ll = new LatLon(point[0], point[1]);
                log.info(ll);
                stops.data.add(new StopMarker(ll, array[2], "tsp_stop", stops, 0, 0, ls.color));
            }
            this.mapView.addLayer(stops, true);

            OsmDataLayer layer = new OsmDataLayer(new DataSet(), "Route Plan " + id_layer++,
                    File.createTempFile("planning", "route"));
            String way2 = plan.getWay();

            if (way2 != null) {
                Way way = new Way();
                LatLon info = null;

                MultiLineString multilinestring = (MultiLineString) wktReader.read(way2);
                multilinestring.getLength();
                int numGeometries = multilinestring.getNumGeometries();
                for (int i = 0; i < numGeometries; i++) {
                    for (Coordinate coordenada : multilinestring.getGeometryN(i).getCoordinates()) {
                        LatLon ll = new LatLon(coordenada.y, coordenada.x);
                        way.addNode(new Node(ll));
                        if (info == null)
                            info = ll;
                    }
                    way.mappaintStyle = ls;
                    layer.data.ways.add(way);
                    way = new Way();
                }
                progressBar.setValue(progressBar.getValue() + 1);

                StopMarker marker = new StopMarker(info,
                        (new Double(plan.getDistance())).toString().substring(0, 5) + " km in "
                                + (new Double(plan.getTime() / 60)).toString().substring(0, 3) + " hours",
                        "tsp_stop", stops, 0, 0, ls.color);
                marker.setPaintIcon(false);
                stops.data.add(marker);
            }
            this.mapView.addLayer(layer, true);

            layer.visible = true;
            stops.visible = true;
        }
    } catch (Throwable e) {
        log.error("Error painting plan", e);
    }
}