Example usage for java.awt Label size

List of usage examples for java.awt Label size

Introduction

In this page you can find the example usage for java.awt Label size.

Prototype

@Deprecated
public Dimension size() 

Source Link

Document

Returns the size of this component in the form of a Dimension object.

Usage

From source file:jspritTest.util.Plotter.java

private void addJob(XYSeries activities, Job job) {
    if (job instanceof Shipment) {
        Shipment s = (Shipment) job;//ww w. j  a  va 2s . co  m
        Coordinate pickupCoordinate = getCoordinate(s.getPickupLocation().getCoordinate());
        XYDataItem dataItem = new XYDataItem(pickupCoordinate.getX() * scalingFactor,
                pickupCoordinate.getY() * scalingFactor);
        activities.add(dataItem);
        addLabel(s, dataItem);
        markItem(dataItem, Activity.PICKUP);
        containsPickupAct = true;

        Coordinate deliveryCoordinate = getCoordinate(s.getDeliveryLocation().getCoordinate());
        XYDataItem dataItem2 = new XYDataItem(deliveryCoordinate.getX() * scalingFactor,
                deliveryCoordinate.getY() * scalingFactor);
        activities.add(dataItem2);
        addLabel(s, dataItem2);
        markItem(dataItem2, Activity.DELIVERY);
        containsDeliveryAct = true;
    } else if (job instanceof Pickup) {
        Pickup service = (Pickup) job;
        Coordinate coord = getCoordinate(service.getLocation().getCoordinate());
        XYDataItem dataItem = new XYDataItem(coord.getX() * scalingFactor, coord.getY() * scalingFactor);
        activities.add(dataItem);
        addLabel(service, dataItem);
        markItem(dataItem, Activity.PICKUP);
        containsPickupAct = true;
    } else if (job instanceof Delivery) {
        Delivery service = (Delivery) job;
        Coordinate coord = getCoordinate(service.getLocation().getCoordinate());
        XYDataItem dataItem = new XYDataItem(coord.getX() * scalingFactor, coord.getY() * scalingFactor);
        activities.add(dataItem);
        addLabel(service, dataItem);
        markItem(dataItem, Activity.DELIVERY);
        containsDeliveryAct = true;
    } else if (job instanceof Service) {
        Service service = (Service) job; //down casting to specific Service class
        Coordinate coord = getCoordinate(service.getLocation().getCoordinate()); //get the service coordinate
        XYDataItem dataItem = new XYDataItem(coord.getX() * scalingFactor, coord.getY() * scalingFactor);
        activities.add(dataItem);
        if (this.label.equals(Label.SIZE))
            addLabel(service, dataItem); //let's see if we can extend this functionality to include additional labels
        else {
            String windowStart = String.valueOf(service.getTimeWindow().getStart());
            String windowEnd = String.valueOf(service.getTimeWindow().getEnd());
            String label = "{ID=" + job.getId() + ":" + windowStart + "-" + windowEnd + "}";
            labelsByDataItem.put(dataItem, label);
        }
        markItem(dataItem, Activity.SERVICE);
        containsServiceAct = true;
    } else {
        throw new IllegalStateException(
                "job instanceof " + job.getClass().toString() + ". this is not supported.");
    }
}

From source file:com.graphhopper.jsprit.analysis.toolbox.Plotter.java

private void addLabel(Job job, XYDataItem dataItem) {
    if (this.label.equals(Label.SIZE)) {
        labelsByDataItem.put(dataItem, getSizeString(job));
    } else if (this.label.equals(Label.ID)) {
        labelsByDataItem.put(dataItem, String.valueOf(job.getId()));
    }/*from ww  w.ja v  a 2s.  c om*/
}