Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
JEuclid Core Source Code Files
JEuclid Source Code Files are provided
the
JEuclid GitHub Website.
You can browse JEuclid Source Code files below:
✍: FYIcenter
⏎ net/sourceforge/jeuclid/elements/support/ElementListSupport.java
/*
* Copyright 2007 - 2007 JEuclid, http://jeuclid.sf.net
*
* 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.
*/
/* $Id$ */
package net.sourceforge.jeuclid.elements.support;
import java.awt.Color;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.jeuclid.layout.FillRectObject;
import net.sourceforge.jeuclid.layout.GraphicsObject;
import net.sourceforge.jeuclid.layout.LayoutInfo;
import net.sourceforge.jeuclid.layout.LayoutStage;
import net.sourceforge.jeuclid.layout.LayoutView;
import net.sourceforge.jeuclid.layout.LayoutableNode;
import org.w3c.dom.Node;
/**
* Class to support Lists of MathElements.
* <p>
* This class can be used by all elements that have some kind of a list of
* children that they need to handle in a row-like manner.
*
* @version $Revision$
*/
public final class ElementListSupport {
private ElementListSupport() {
// Utility class.
}
/**
* Creates a list of children for the given Element.
*
* @param parent
* the parent element.
* @return list of Children.
*/
public static List<Node> createListOfChildren(final Node parent) {
final org.w3c.dom.NodeList childList = parent.getChildNodes();
final int len = childList.getLength();
final List<Node> children = new ArrayList<Node>(len);
for (int i = 0; i < len; i++) {
final Node child = childList.item(i);
children.add(child);
}
return children;
}
/**
* Creates a list of layoutable children for the given Element.
*
* @param parent
* the parent element.
* @return list of Children.
*/
public static List<LayoutableNode> createListOfLayoutChildren(
final Node parent) {
final org.w3c.dom.NodeList childList = parent.getChildNodes();
final int len = childList.getLength();
final List<LayoutableNode> children = new ArrayList<LayoutableNode>(len);
for (int i = 0; i < len; i++) {
final Node child = childList.item(i);
if (child instanceof LayoutableNode) {
children.add((LayoutableNode) child);
}
}
return children;
}
/**
* @param view
* View Object
* @param info
* Info to fill
* @param parent
* Current Node
* @param stage
* Stage to load Info From
* @param borderLeftTop
* border around element.
* @param borderRightBottom
* border around element.
*/
public static void fillInfoFromChildren(final LayoutView view,
final LayoutInfo info, final Node parent, final LayoutStage stage,
final Dimension2D borderLeftTop, final Dimension2D borderRightBottom) {
float ascentHeight = (float) borderLeftTop.getHeight();
float descentHeight = (float) borderRightBottom.getHeight();
final float startX = (float) borderLeftTop.getWidth();
float width = startX;
for (final LayoutableNode child : ElementListSupport
.createListOfLayoutChildren(parent)) {
final LayoutInfo childInfo = view.getInfo(child);
ascentHeight = Math.max(ascentHeight, -childInfo.getPosY(stage)
+ childInfo.getAscentHeight(stage));
descentHeight = Math.max(descentHeight, childInfo.getPosY(stage)
+ childInfo.getDescentHeight(stage));
width = Math.max(width, childInfo.getPosX(stage)
+ childInfo.getWidth(stage));
}
info.setAscentHeight(ascentHeight + (float) borderLeftTop.getHeight(),
stage);
info.setDescentHeight(descentHeight
+ (float) borderRightBottom.getHeight(), stage);
info.setHorizontalCenterOffset((width + startX) / 2.0f, stage);
info.setWidth(width + (float) borderRightBottom.getWidth(), stage);
}
/**
* @param view
* View Object
* @param info
* Info to fill
* @param children
* Children to layout
* @param stage
* Stage to load Info From
*/
public static void layoutSequential(final LayoutView view,
final LayoutInfo info, final List<LayoutableNode> children,
final LayoutStage stage) {
float ascentHeight = 0.0f;
float descentHeight = 0.0f;
float posX = 0.0f;
float stretchAscent = 0.0f;
float stretchDescent = 0.0f;
for (final LayoutableNode child : children) {
final LayoutInfo childInfo = view.getInfo(child);
ascentHeight = Math.max(ascentHeight, childInfo
.getAscentHeight(stage));
descentHeight = Math.max(descentHeight, childInfo
.getDescentHeight(stage));
stretchAscent = Math.max(stretchAscent, childInfo
.getStretchAscent());
stretchDescent = Math.max(stretchDescent, childInfo
.getStretchDescent());
childInfo.moveTo(posX, 0.0f, stage);
posX += childInfo.getWidth(stage);
}
info.setAscentHeight(ascentHeight, stage);
info.setDescentHeight(descentHeight, stage);
info.setStretchAscent(stretchAscent);
info.setStretchDescent(stretchDescent);
info.setHorizontalCenterOffset(posX / 2.0f, stage);
info.setWidth(posX, stage);
}
/**
* Add a background Rectangle for the given background color.
*
* @param backgroundColor
* background color (may be null)
* @param info
* LayoutInfo object to add to. Must already be completely
* rendered (stage 2)
* @param useCeil
* if true, the {@link Math#ceil(double)} will be used to avoid
* anti-aliasing artifacts.
*/
public static void addBackground(final Color backgroundColor,
final LayoutInfo info, final boolean useCeil) {
if (backgroundColor != null) {
final GraphicsObject fillObject;
if (useCeil) {
fillObject = new FillRectObject(backgroundColor, (float) Math
.ceil(info.getAscentHeight(LayoutStage.STAGE2)),
(float) Math.ceil(info
.getDescentHeight(LayoutStage.STAGE2)),
(float) Math.ceil(info.getWidth(LayoutStage.STAGE2)));
} else {
fillObject = new FillRectObject(backgroundColor, info
.getAscentHeight(LayoutStage.STAGE2), info
.getDescentHeight(LayoutStage.STAGE2), info
.getWidth(LayoutStage.STAGE2));
}
info.getGraphicObjects().add(0, fillObject);
}
}
}
⏎ net/sourceforge/jeuclid/elements/support/ElementListSupport.java
Or download all of them as a single archive file:
File name: jeuclid-core-3.1.14-fyi.zip File size: 325716 bytes Release date: 2019-02-24 Download
⇒ Using JEuclid 3.1.9 on macOS
⇐ Download and Install jeuclid-core-3.1.14.jar
2025-08-15, ≈63🔥, 0💬
Popular Posts:
JDK 17 java.sql.jmod is the JMOD file for JDK 17 SQL (Structured Query Language) module. JDK 17 SQL ...
commons-lang-1.0.1.jar is the JAR file for Apache Commons Lang 1.0.1, which provides a host of helpe...
JRE 8 plugin.jar is the JAR file for JRE 8 Java Control Panel Plugin interface and tools. JRE (Java ...
JDK 11 jdk.management.agent.jmo dis the JMOD file for JDK 11 Management Agent module. JDK 11 Managem...
maven-model-builder-3.8. 6.jaris the JAR file for Apache Maven 3.8.6 Model Builder module. Apache Ma...