1// BEGIN LICENSE BLOCK 2// Version: CMPL 1.1 3// 4// The contents of this file are subject to the Cisco-style Mozilla Public 5// License Version 1.1 (the "License"); you may not use this file except 6// in compliance with the License. You may obtain a copy of the License 7// at www.eclipse-clp.org/license. 8// 9// Software distributed under the License is distributed on an "AS IS" 10// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 11// the License for the specific language governing rights and limitations 12// under the License. 13// 14// The Original Code is CPViz Constraint Visualization System 15// The Initial Developer of the Original Code is Helmut Simonis 16// Portions created by the Initial Developer are 17// Copyright (C) 2009-2010 Helmut Simonis 18// 19// Contributor(s): Helmut Simonis, 4C, Univerity College Cork, Cork 20// 21// 22// END LICENSE BLOCK 23// ---------------------------------------------------------------------- 24package ie.ucc.cccc.viz; 25 26import java.io.PrintWriter; 27 28/** 29 * Simple Visualizer for a 2D non overallping constraint disjoint2 30 * This does not exist in ECLiPSe, just checking the interface code 31 * @author hsimonis 32 * 33 */ 34public class VisualizerDisjoint2D extends VisualizerLayout { 35 36 public VisualizerDisjoint2D(VisualContext context){ 37 super(context); 38 } 39 40 @Override 41 void draw(PrintWriter out, VisualState visualState) { 42 Tuple[] rect = visualState.argumentTupleArray("1"); 43 FullDomain width = visualState.argumentDomain("2"); 44 FullDomain height = visualState.argumentDomain("3"); 45 46 int n = rect.length; 47 setWidth(width.getMax()); 48 setHeight(height.getMax()); 49 setMin(0); 50 51 standardGrid(out); 52 // draw rectangles 53 for(int i=1;i<n;i++) { 54 int x1 = rect[i].getField("x").getMin(); 55 int y1 = rect[i].getField("y").getMin(); 56 int x2 = rect[i].getField("x").getMax(); 57 int y2 = rect[i].getField("y").getMax(); 58 int w1 = rect[i].getField("w").getMin(); 59 int h1 = rect[i].getField("h").getMin(); 60 if (x1 == x2 && y1 == y2) { 61 rectSVG(out,posX(x1),posY(y1), 62 w1,h1,Colors.ASSIGN_COLOR); 63 } else { 64 rectSVG(out,posX(x1),posY(y1), 65 x2-x1+w1,(y2-y1+h1),Colors.UNASSIGNED_COLOR,0.3); 66 67 } 68 } 69 } 70 71 72} 73