static void refreshGrid() { if (styleGrid != null) { styleGrid.dispose(); shell.pack(); } styleGrid = new Group(shell, SWT.NONE); styleGrid.setText(xAxis.getName() + " vs. " + yAxis.getName()); styleGrid.setLayout(new GridLayout(xAxis.getCount() + 1, false)); styleGrid.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, true, 1, 1)); // put blank label in top left corner Label label = new Label(styleGrid, SWT.NONE); // add x-axis labels for (int x = 0; x < xAxis.getCount(); x++) { label = new Label(styleGrid, SWT.NONE); label.setText(xAxis.getName() + " =\n" + xAxis.getAt(x).getName()); } // iterate over the y-axis style settings for (int y = 1; y < yAxis.getCount() + 1; y++) { // add y-axis label for this row label = new Label(styleGrid, SWT.NONE); label.setText(yAxis.getName() + " =\n" + yAxis.getAt(y - 1).getName()); // iterate over the x-axis style settings for (int x = 1; x < xAxis.getCount() + 1; x++) { // create a sample shape instance Shape shape; if (sampleShape == Polyline.class) { Polyline poly = new Polyline(); poly.addPoint(new Point(20, 20)); poly.addPoint(new Point(50, 80)); poly.addPoint(new Point(10, 50)); shape = poly; } else { try { shape = (Shape) sampleShape.getConstructor(null).newInstance(null); } catch (Exception e) { throw new RuntimeException( "Could not find a no args constructor for " + sampleShape.getName()); } shape.setBounds(new Rectangle(0, 0, 100, 75)); } // apply default style shape.setBackgroundColor(ColorConstants.orange()); shape.setLineWidthFloat(defaultLineWidth); shape.setAntialias(SWT.ON); // apply styles imposed by each axis xAxis.applyTo(shape, x - 1); yAxis.applyTo(shape, y - 1); FigureCanvas figureBox = new FigureCanvas(styleGrid); figureBox.setContents(shape); } } shell.pack(); }
public void applyTo(Shape shape, int i) { shape.setAntialias((int) elements[i].getValue()); }