mirror of
https://github.com/octoleo/plantuml.git
synced 2024-06-08 19:22:25 +00:00
145 lines
3.8 KiB
Java
145 lines
3.8 KiB
Java
|
/* ========================================================================
|
||
|
* PlantUML : a free UML diagram generator
|
||
|
* ========================================================================
|
||
|
*
|
||
|
* (C) Copyright 2009, Arnaud Roques
|
||
|
*
|
||
|
* Project Info: http://plantuml.sourceforge.net
|
||
|
*
|
||
|
* This file is part of PlantUML.
|
||
|
*
|
||
|
* PlantUML is free software; you can redistribute it and/or modify it
|
||
|
* under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation, either version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* PlantUML distributed in the hope that it will be useful, but
|
||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||
|
* License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public
|
||
|
* License along with this library; if not, write to the Free Software
|
||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||
|
* USA.
|
||
|
*
|
||
|
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||
|
* in the United States and other countries.]
|
||
|
*
|
||
|
* Original Author: Arnaud Roques
|
||
|
*
|
||
|
* Revision $Revision: 3836 $
|
||
|
*
|
||
|
*/
|
||
|
package net.sourceforge.plantuml.sequencediagram.graphic;
|
||
|
|
||
|
import net.sourceforge.plantuml.graphic.HorizontalAlignement;
|
||
|
|
||
|
public class SequenceDiagramArea {
|
||
|
|
||
|
private final double sequenceWidth;
|
||
|
private final double sequenceHeight;
|
||
|
|
||
|
private double headerWidth;
|
||
|
private double headerHeight;
|
||
|
private double headerMargin;
|
||
|
|
||
|
private double titleWidth;
|
||
|
private double titleHeight;
|
||
|
|
||
|
private double footerWidth;
|
||
|
private double footerHeight;
|
||
|
private double footerMargin;
|
||
|
|
||
|
public SequenceDiagramArea(double width, double height) {
|
||
|
this.sequenceWidth = width;
|
||
|
this.sequenceHeight = height;
|
||
|
}
|
||
|
|
||
|
public void setTitleArea(double titleWidth, double titleHeight) {
|
||
|
this.titleWidth = titleWidth;
|
||
|
this.titleHeight = titleHeight;
|
||
|
}
|
||
|
|
||
|
public void setHeaderArea(double headerWidth, double headerHeight, double headerMargin) {
|
||
|
this.headerWidth = headerWidth;
|
||
|
this.headerHeight = headerHeight;
|
||
|
this.headerMargin = headerMargin;
|
||
|
}
|
||
|
|
||
|
public void setFooterArea(double footerWidth, double footerHeight, double footerMargin) {
|
||
|
this.footerWidth = footerWidth;
|
||
|
this.footerHeight = footerHeight;
|
||
|
this.footerMargin = footerMargin;
|
||
|
}
|
||
|
|
||
|
public double getWidth() {
|
||
|
double result = sequenceWidth;
|
||
|
if (headerWidth > result) {
|
||
|
result = headerWidth;
|
||
|
}
|
||
|
if (titleWidth > result) {
|
||
|
result = titleWidth;
|
||
|
}
|
||
|
if (footerWidth > result) {
|
||
|
result = footerWidth;
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
public double getHeight() {
|
||
|
return sequenceHeight + headerHeight + headerMargin + titleHeight + footerMargin + footerHeight;
|
||
|
}
|
||
|
|
||
|
public double getTitleX() {
|
||
|
return (getWidth() - titleWidth) / 2;
|
||
|
}
|
||
|
|
||
|
public double getTitleY() {
|
||
|
return headerHeight + headerMargin;
|
||
|
}
|
||
|
|
||
|
public double getSequenceAreaX() {
|
||
|
return (getWidth() - sequenceWidth) / 2;
|
||
|
}
|
||
|
|
||
|
public double getSequenceAreaY() {
|
||
|
return getTitleY() + titleHeight;
|
||
|
}
|
||
|
|
||
|
public double getHeaderY() {
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
public double getFooterY() {
|
||
|
return sequenceHeight + headerHeight + headerMargin + titleHeight + footerMargin;
|
||
|
}
|
||
|
|
||
|
public double getFooterX(HorizontalAlignement align) {
|
||
|
if (align == HorizontalAlignement.LEFT) {
|
||
|
return 0;
|
||
|
}
|
||
|
if (align == HorizontalAlignement.RIGHT) {
|
||
|
return getWidth() - footerWidth;
|
||
|
}
|
||
|
if (align == HorizontalAlignement.CENTER) {
|
||
|
return (getWidth() - footerWidth) / 2;
|
||
|
}
|
||
|
throw new IllegalStateException();
|
||
|
}
|
||
|
|
||
|
public double getHeaderX(HorizontalAlignement align) {
|
||
|
if (align == HorizontalAlignement.LEFT) {
|
||
|
return 0;
|
||
|
}
|
||
|
if (align == HorizontalAlignement.RIGHT) {
|
||
|
return getWidth() - headerWidth;
|
||
|
}
|
||
|
if (align == HorizontalAlignement.CENTER) {
|
||
|
return (getWidth() - headerWidth) / 2;
|
||
|
}
|
||
|
throw new IllegalStateException();
|
||
|
}
|
||
|
|
||
|
}
|