// PathVisio,
// a tool for data visualization and analysis using Biological Pathways
// Copyright 2006-2009 BiGCaT Bioinformatics
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package org.pathvisio.model;

import java.awt.Shape;

import org.pathvisio.view.ShapeRegistry;

public class AbstractShape implements IShape
{
	private String name;
	private String mappName;
	private boolean isResizeable;
	private boolean isRotatable;
	
	public AbstractShape (String name, String mappName, boolean isResizeable, boolean isRotatable)
	{
		this.name = name;
		this.mappName = mappName;
		this.isRotatable = isRotatable;
		this.isResizeable = isResizeable;
	}
	
	@Override
	public String getMappName()
	{
		return mappName;
	}

	@Override
	public String getName()
	{
		return name;
	}

	@Override
	public Shape getShape(double mw, double mh)
	{
		return ShapeRegistry.getShape(name, 0, 0, mw, mh);		
	}

	@Override
	public boolean isResizeable()
	{
		return isResizeable;
	}

	@Override
	public boolean isRotatable()
	{
		return isRotatable;
	}
	
	public String toString()
	{
		return name;
	}

}

@@ -731,55 +731,78 @@
 awt.
-Shap
+Rectangl
 e;%0A
-%0A
 import 
-org.pathvisio.view.ShapeRegistry
+java.awt.Shape;%0Aimport java.awt.geom.AffineTransform
 ;%0A%0Ap
@@ -956,16 +956,35 @@
 atable;%0A
+%09private Shape sh;%0A
 %09%0A%09publi
@@ -1000,16 +1000,26 @@
 tShape (
+Shape sh, 
 String n
@@ -1102,24 +1102,40 @@
 ame = name;%0A
+%09%09this.sh = sh;%0A
 %09%09this.mappN
@@ -1223,17 +1223,106 @@
 ble;%0A%09%7D%0A
-%09
+%0A%09public AbstractShape (Shape sh, String name)%0A%09%7B%0A%09%09this (sh, name, name, true, true);%0A%09%7D%0A
 %0A%09@Overr
@@ -1503,60 +1503,249 @@
 %7B%0A%09%09
-return ShapeRegistry.getShape(name, 0, 0, mw, mh
+// now scale the path so it has proper w and h.%0A%09%09Rectangle r = sh.getBounds();%0A%09%09AffineTransform at = new AffineTransform();%0A%09%09at.translate ( - r.x,  - r.y);%0A%09%09at.scale (mw / r.width, mh / r.height
 );
+%0A
 %09%09
+return at.createTransformedShape (sh);
 %0A%09%7D%0A

Make AbstractShape independent of ShapeRegistry