/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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.apache.tuscany.sca.impl.artifacts; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Service extends Artifact{ // private static final int COMMON_LENGTH = 20 ; // public static Element addServiceElement(Document document, String svgNs, int midX, int midY) { // // Create the rectangle. // Element polygon = document.createElementNS(svgNs, "polygon"); // polygon.setAttributeNS(null, "points", // ""+ (midX-COMMON_LENGTH) +","+midY+" " + // ""+ (midX+(COMMON_LENGTH/2)) +","+midY+" " + // ""+ (midX+COMMON_LENGTH) +","+(midY-COMMON_LENGTH)+" " + // ""+ (midX+(COMMON_LENGTH/2)) +","+(midY-COMMON_LENGTH*2)+" " + // ""+ (midX-COMMON_LENGTH) +","+(midY-COMMON_LENGTH*2)+" " + // ""+ (midX-(COMMON_LENGTH/2)) +","+(midY-COMMON_LENGTH)+" " // ); // polygon.setAttributeNS(null, "fill", "#00CD66"); // polygon.setAttributeNS(null, "stroke", "#008B45"); // // return polygon; // } public Element addElement(Document document, String svgNs, int x, int y, int height, int width) { return this.addElement(document, svgNs, x, y, height); } /** * In a Service the (x,y) coordinates refers to the inner edge of the polygon * ______ * \ \ * inner edge ____ \ \ * / / * /____ / * * @param document * @param svgNs * @param x * @param y * @param height * @return */ public Element addElement(Document document, String svgNs, int x, int y, int height) { this.setHeight(height); this.setWidth(height); this.setxCoordinate(x); this.setyCoordinate(y); int length = height/2; Element polygon = document.createElementNS(svgNs, "polygon"); polygon.setAttributeNS(null, "points", ""+ x +","+y+" " + ""+ (x-length) +","+(y-length)+" " + ""+ (x+length) +","+(y-length)+" " + ""+ (x+(length*2)) +","+y+" " + ""+ (x+length) +","+(y+length)+" " + ""+ (x-length) +","+(y+length)+" " ); polygon.setAttributeNS(null, "fill", "#00CD66"); polygon.setAttributeNS(null, "stroke", "#008B45"); return polygon; } }