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
28public abstract class VisualizerGraph extends VisualizerDrawer {
29
30	public VisualizerGraph(VisualContext context){
31		super(context);
32	}
33
34	@Override
35	void draw(PrintWriter out, VisualState visualState) {
36	}
37
38	@Override public void standardGrid(PrintWriter out){
39		// grid for rect
40
41		rectSVG(out,leftX(),labelY(),
42				width(),height(),Colors.WHITE_COLOR);
43		// horizontal value labels
44		for(int i=0;i<=width();i++){
45			textSVG(out,posX(i),labelY()+0.8,0.5,
46					i,Colors.LABEL_TEXT_COLOR);
47		}
48		// vertical value labels
49//		for(int i=0;i<=height();i++){
50//			textSVG(out,labelX()+0.5,posY(i)+0.2,0.5,
51//					i,Colors.LABEL_TEXT_COLOR);
52//		}
53	}
54
55
56	@Override public double posX(double x){
57		return context.getX()+1+x;
58	}
59	@Override public double posY(double y){
60		return context.getY()+1+height()-height()*y/max();
61	}
62	@Override public int labelY() {
63		return context.getY()+height()+1;
64	}
65
66	@Override public void rectSVG(PrintWriter out,double x, double y,
67			double width, double height, Colors color) {
68		super.rectSVG(out, x, y-height, width, height, color);
69	}
70
71	@Override public void rectSVG(PrintWriter out,double x, double y,
72			double width, double height, Colors color,double opacity) {
73		super.rectSVG(out, x, y-height, width, height, color,opacity);
74	}
75
76
77}
78