All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sqlapp.graphviz.labeltable.TableElement Maven / Gradle / Ivy

There is a newer version: 0.12.37
Show newest version
/**
 * Copyright (C) 2007-2017 Tatsuo Satoh 
 *
 * This file is part of sqlapp-graphviz.
 *
 * sqlapp-graphviz is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * sqlapp-graphviz is 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 Lesser General Public License
 * along with sqlapp-graphviz.  If not, see .
 */

package com.sqlapp.graphviz.labeltable;

import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

import javax.xml.stream.XMLStreamException;

import com.sqlapp.graphviz.GraphVizElementUtils;
import com.sqlapp.graphviz.Node;
import com.sqlapp.graphviz.Port;
import com.sqlapp.graphviz.PortCollection;
import com.sqlapp.util.StaxWriter;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

@Accessors(chain=true) 
@Getter
@Setter
@EqualsAndHashCode(callSuper=true)
public class TableElement extends AbstractHtmlElement{
	
	public TableElement(){}

	public TableElement(Node node){
		super(node);
	}
	
	/**
	 * default CENTER
	 */
	private Align align=null;
	/**
	 * default CENTER
	 */
	private Align balign=null;
	private String bgcolor;
	/**
	 * default 1
	 * maximum 255
	 */
	private Integer border=null;
	/**
	 * default 2
	 * maximum 255
	 */
	private Integer cellpadding=null;
	/**
	 * default 2
	 * maximum 127
	 */
	private Integer cellspacing;
	private String color;
	private boolean fixedsize=false;
	private String gradientAngle;
	private String height;
	private String href;
	private String id;
	private Port port;
	private String sides;
	private String style;
	private String target;
	private String title;
	private String tooltip;
	private String width;
	private VAlign valign;
	
	private List rows=new ArrayList<>();

	protected PortCollection getPorts(){
		return GraphVizElementUtils.getPorts(this.getRoot().getNode());
	}
	
	
	protected String getElementName(){
		return "table";
	}
	
	public TableElement setPort(String value){
		Port port=new Port(value);
		GraphVizElementUtils.setParent(port, this.getRoot().getNode());
		this.port=port;
		return instance();
	}

	public TableElement addRow(Consumer c){
		TrElement tr=new TrElement();
		tr.setParent(this);
		this.rows.add(tr);
		c.accept(tr);
		return instance();
	}
	
	public TableElement addRow(int index, Consumer c){
		TrElement tr=new TrElement();
		tr.setParent(this);
		this.rows.add(index, tr);
		c.accept(tr);
		return instance();
	}
	
	public TableElement addRows(BiConsumer c, int rowSize){
		for(int i=0;i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy