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 * Abstract class for a layout display, both axis are drawn from 0, with the coordinates
30 * going up and to the right
31 * To work completely, it needs to redefine the drawing primitives to handle the
32 * changed system, currently only done partially
33 * @author hsimonis
34 *
35 */
36public abstract class VisualizerLayout extends VisualizerDrawer {
37
38	public VisualizerLayout(VisualContext context){
39		super(context);
40	}
41
42	@Override
43	void draw(PrintWriter out, VisualState visualState) {
44	}
45
46	@Override public void standardGrid(PrintWriter out){
47		// grid for rect
48
49		gridSVG(out,leftX(),topY(),
50				width(),height());
51		// horizontal value labels
52		for(int i=0;i<=width();i++){
53			textSVG(out,posX(i),labelY()+0.8,0.5,
54					i,Colors.LABEL_TEXT_COLOR);
55		}
56		// vertical value labels
57		for(int i=0;i<=height();i++){
58			textSVG(out,labelX()+0.5,posY(i)+0.2,0.5,
59					i,Colors.LABEL_TEXT_COLOR);
60		}
61	}
62
63	public void drawLimit(PrintWriter out,FullDomain limit){
64		openRectSVG(out,leftX(),posY(limit.getMin()),width(),
65				posY(limit.getMax())-posY(limit.getMin()),Colors.TOO_HIGH_COLOR,0.2);
66		lineSVG(out,leftX(),posY(limit.getMin()),
67				leftX()+width(),posY(limit.getMin()),Colors.TOO_HIGH_COLOR);
68		lineSVG(out,leftX(),posY(limit.getMax()),
69				leftX()+width(),posY(limit.getMax()),Colors.TOO_HIGH_COLOR);
70
71	}
72	public void drawEnd(PrintWriter out, FullDomain end){
73		if (end != null){
74			openRectSVG(out,posX(end.getMin()),topY()+height(),
75					posX(end.getMax())-posX(end.getMin()),height(),
76					Colors.TOO_HIGH_COLOR,0.2);
77			lineSVG(out,posX(end.getMin()),topY(),
78					posX(end.getMin()),topY()+height(),Colors.TOO_HIGH_COLOR);
79			lineSVG(out,posX(end.getMax()),topY(),
80					posX(end.getMax()),topY()+height(),Colors.TOO_HIGH_COLOR);
81		}
82
83	}
84
85	@Override public double posX(double x){
86		return context.getX()+1+x;
87	}
88	@Override public double posY(double y){
89		return context.getY()+1+height()-y;
90	}
91	@Override public int labelY() {
92		return context.getY()+height()+1;
93	}
94
95	@Override public void rectSVG(PrintWriter out,double x, double y,
96			double width, double height, Colors color) {
97		super.rectSVG(out, x, y-height, width, height, color);
98	}
99
100	@Override public void rectSVG(PrintWriter out,double x, double y,
101			double width, double height, Colors color,double opacity) {
102		super.rectSVG(out, x, y-height, width, height, color,opacity);
103	}
104
105	@Override public void openRectSVG(PrintWriter out,double x, double y,
106			double width, double height, Colors color,double opacity) {
107		super.openRectSVG(out, x, y-height, width, height, color,opacity);
108	}
109	@Override public void openRectSVG(PrintWriter out,double x, double y,
110			double width, double height, Colors color) {
111		super.openRectSVG(out, x, y-height, width, height, color);
112	}
113	@Override public void roundedRectSVG(PrintWriter out,double x, double y,
114			double width, double height, Colors color,double opacity) {
115		super.roundedRectSVG(out, x, y-height, width, height, color,opacity);
116	}
117	@Override public void roundedRectSVG(PrintWriter out,double x, double y,
118			double width, double height, Colors color) {
119		super.roundedRectSVG(out, x, y-height, width, height, color);
120	}
121}
122