1

I am new using JFree. I would like to know how to create my data set in a way that all opeartion of a particular job have the same color (e.g., O111, O122, O133, O144 with the same color, with machines in lines as the image 2).

I tryed to make it using TaskSeries but it creates a graph with one line for each operation. As the image bellow.

enter image description here

But I want one line for each machine, as the image bellow:

enter image description here

However, I would like to define a color for each job and its respective operations.

My dataset creation:

public static IntervalCategoryDataset createDataset(Map<Integer, LinkedList<Operation>> lines, Integer makespan) {

    /*Map<Integer, TaskSeries> mapSeries = new HashMap<>();

    for (Map.Entry<Integer, LinkedList<Operation>> entry : lines.entrySet()) {
        for (int k = 0; k < entry.getValue().size(); k++) {
            if (mapSeries.get(entry.getValue().get(k).getJ().getId()) == null) {
                TaskSeries series = new TaskSeries("Job " + entry.getValue().get(k).getJ().getId());
                mapSeries.put(entry.getValue().get(k).getJ().getId(), series);
            }
        }
    }*/

    TaskSeries seriesOne = new TaskSeries("Scheduled");

    for (Map.Entry<Integer, LinkedList<Operation>> entry : lines.entrySet()) {
        Task mainTask = new Task("Machine" + entry.getKey(), new SimpleTimePeriod(0, makespan));

        for (int k = 0; k < entry.getValue().size(); k++) {

            Task subtask = new Task(entry.getValue().get(k).getName(),
                    new SimpleTimePeriod(entry.getValue().get(k).getStart(), entry.getValue().get(k).getEnd()));

            subtask.setDescription(entry.getValue().get(k).getName());
            //mapSeries.get(entry.getValue().get(k).getJ().getId()).add(subtask);
            mainTask.addSubtask(subtask);
        }
        seriesOne.add(mainTask);
        System.out.println();
    }

    final TaskSeriesCollection collection = new TaskSeriesCollection();
    collection.add(seriesOne); 

    return collection;
}

I also would like to check if anyone knows how to change the Axis to Integer time Units (e.g., 0 1 2 3 4 5 6 7 8 9 10, ..., makespan).

[edit]

I will add more informations needed to reproduce my problem. Input:

    Machine m1 = new Machine(1);
    Machine m2 = new Machine(2);
    Machine m3 = new Machine(3);

    Job j1 = new Job(1);
    Job j2 = new Job(2);
    Job j3 = new Job(3);

    j1.setSequence(new ArrayList<OperationSeq>(Arrays.asList(
            new OperationSeq[] { new OperationSeq(m1, 7), new OperationSeq(m3, 8), new OperationSeq(m2, 10) })));
    j2.setSequence(new ArrayList<OperationSeq>(Arrays.asList(
            new OperationSeq[] { new OperationSeq(m2, 6), new OperationSeq(m1, 4), new OperationSeq(m3, 12) })));
    j3.setSequence(new ArrayList<OperationSeq>(Arrays.asList(
            new OperationSeq[] { new OperationSeq(m1, 8), new OperationSeq(m2, 8), new OperationSeq(m3, 7) })));

Data model: I am using a

    Map<Integer, LinkedList<Operation>>

where the key value is the machine id and the LinkedList is the operation which needs to be placed in the machine row.

Every Operation contains its respective Job id, its Sequence id, machine id, and a time interval Integer start, Integer end (e.g., Operation from Job 1, Sequence 1 (the first operation of the Job 1), Machine 1, start=0, end=3).

So based on this description we can see that every map key value will be a row in the chart, and each operation will be a column. Then, what I want is to change the color of the Task based on the Operation Job id.

The image bellow reproduce exactly what I want.

Exactly what I want

WillEnsaba
  • 756
  • 1
  • 8
  • 23

1 Answers1

2
  1. All operations of a particular job have the same color.

    Use the same TaskSeries to get the first color from the default DrawingSupplier, as shown here.

    same color

  2. Define a color for each job and its respective operations.

    Override getItemPaint() to supply the desired color; this example supplies a palette of varying saturations for each subtask.

    different color

  3. Change the Axis to Integer time units.

    The DateAxis instantiated by the relevant ChartFactory interprets data values as milliseconds from the Java epoch; to alter the display, override setDateFormatOverride() with the desired format, as shown here.

    integer ticks

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • I am posting a image just to be sure that I can accomplish it with the answer for the question 1 and 2. I would like to represent each operation in its respective machine. Each operation of Job n, with the color n, and operations of Job n+1, with the color n+1. I think with the image will be more clear. http://i.imgur.com/WS6DoTA.png – WillEnsaba Nov 04 '16 at 12:00
  • I don't understand your data model, but the view looks feasible; please [edit](http://stackoverflow.com/posts/40402219/edit) your question to include your image and a [mcve] that shows your revised approach. – trashgod Nov 04 '16 at 15:37
  • Dear trashgod, I added more parts needed to reproduce my problem. – WillEnsaba Nov 07 '16 at 12:05
  • I don't understand the parts. Please edit your question to include a [mcve] that exhibits the problem you describe. – trashgod Nov 07 '16 at 12:22
  • But you only needs to understand the Map>. If you get it you will understand everything. Every key is the row, every value is the column (operation) which contains the time interval. That is what I want to plot on the chart. – WillEnsaba Nov 07 '16 at 12:46
  • I dont understand why there is not a method to allow me to define the color when I creating the Tasks/Serie. Like if (something), task.setColor(Color.Black). Would be sooooo easy. But in this case it would not generate the subtitles like in my image 1. – WillEnsaba Nov 07 '16 at 12:48
  • Perhaps easy, but it would represent a design that scales poorly; two common approaches are contrasted [here](http://stackoverflow.com/a/16754801/230513). – trashgod Nov 07 '16 at 13:04