Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace JavaFX text with AWT #63

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ jobs:
ls -al .
sudo apt install gnupg1

- name: start xvfb
run:
Xvfb :0 &

- name: initialize the X11 DISPLAY variable
run:
export DISPLAY=:0

- name: Install libraries
run: |
sudo apt update
sudo apt install libgtk2.0-0

- name: Test with Gradle
run: xvfb-run -s '-screen 0 1024x768x24' ./gradlew test

- name: Publish package
run: bash publish.sh
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public static int getBuildVersion() {
public static int[] getBuildInfo() {
String s = getVersion();
String[] splits = s.split("[.]+");
if (splits.length == 1) {
return new int[]{0, 0, 0};
}

int[] rev = new int[3];
for (int i = 0; i < 3; i++) {
rev[i] = new Integer(splits[i]);
Expand Down
17 changes: 5 additions & 12 deletions src/main/java/eu/mihosoft/vrl/v3d/CSG.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import eu.mihosoft.vrl.v3d.parametrics.LengthParameter;
import eu.mihosoft.vrl.v3d.parametrics.Parameter;

import java.awt.Font;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -62,7 +63,6 @@
import javafx.scene.shape.CullFace;
import javafx.scene.shape.DrawMode;
import javafx.scene.shape.MeshView;
import javafx.scene.text.Font;
import javafx.scene.transform.Affine;

/**
Expand Down Expand Up @@ -1257,7 +1257,7 @@ public CSG difference(CSG csg) {
* @return the csg
*/
private CSG _differenceCSGBoundsOpt(CSG csg) {
CSG a1 = this._differenceNoOpt(csg.getBounds().toCSG());
CSG a1 = this._differenceNoOpt(csg.getBounds().toCSG().setColor(csg.getColor()));
CSG a2 = this.intersect(csg.getBounds().toCSG());
CSG result = a2._differenceNoOpt(csg)._unionIntersectOpt(a1).optimization(getOptType());
if (getName().length() != 0 && csg.getName().length() != 0) {
Expand Down Expand Up @@ -2969,23 +2969,16 @@ public int getPrintBedIndex() {
}

public static CSG text(String text, double height, double fontSize) {
return text(text, height, fontSize, Font.getDefault().getName());
return text(text, height, fontSize, Font.SANS_SERIF);
}

public static CSG text(String text, double height) {
return text(text, height, 30);
}

public static CSG text(String text, double height, double fontSize, String fontType) {
javafx.scene.text.Font font = new javafx.scene.text.Font(fontType, fontSize);
if (!font.getName().toLowerCase().contains(fontType.toLowerCase())) {
String options = "";
for (String name : javafx.scene.text.Font.getFontNames()) {
options += name + "\n";
}
new Exception(options + "\nIs Not " + fontType + " instead got " + font.getName()).printStackTrace();
}
ArrayList<CSG> stuff = TextExtrude.text(height, text, font);
Font font = new Font(fontType, Font.PLAIN, (int)fontSize);
List<CSG> stuff = TextExtrude.text(height, text, font);
CSG back = null;
for (int i = 0; i < stuff.size(); i++) {
if (back == null)
Expand Down
83 changes: 40 additions & 43 deletions src/main/java/eu/mihosoft/vrl/v3d/Text3d.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
* Text3d.java
*
* <p>
* Copyright 2014-2016 Michael Hoffer [email protected]. All rights
* reserved.
*
* <p>
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* <p>
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* <p>
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* <p>
* THIS SOFTWARE IS PROVIDED BY Michael Hoffer [email protected] "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Expand All @@ -25,7 +25,7 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* <p>
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of Michael Hoffer
Expand All @@ -35,73 +35,70 @@

import java.util.ArrayList;
import java.util.List;
import java.awt.Font;
import java.util.logging.Level;
import java.util.logging.Logger;

import javafx.scene.text.Font;
/**
* 3d text primitive.
*
* 3d text primitive.
*
* @author Michael Hoffer [email protected]
*/
public class Text3d extends Primitive {

private final static Logger LOGGER = Logger.getLogger(Text3d.class.getName());
private final PropertyStorage properties = new PropertyStorage();
private final ArrayList<CSG> letters = new ArrayList<CSG>();
private final List<CSG> letters = new ArrayList<>();

/**
* Constructor.
*
*
* @param text text
*/
public Text3d(String text) {
this(text, "Arial", 12, 1.0);
this(text, Font.SANS_SERIF, 12, 1.0);
}

/**
* Constructor.
*
* @param text text
*
* @param text text
* @param depth text depth (z thickness)
*/
public Text3d(String text, double depth) {
this(text, "Arial", 12, depth);
this(text, Font.SANS_SERIF, 12, depth);
}

/**
* Constructor.
*
* @param text text
* Constructor.
*
* @param text text
* @param fontName font name, e.g., "Arial"
* @param fontSize font size
* @param depth text depth (z thickness)
* @param depth text depth (z thickness)
*/
public Text3d(String text, String fontName, double fontSize, double depth) {
Font font = new Font(fontName, Font.PLAIN, (int) fontSize);
if (!font.getFamily().equalsIgnoreCase(fontName)) {
LOGGER.log(Level.INFO, String.format("Fontname '%s' was not found, defaulting to '%s'", fontName, font.getFamily()));
}

Font font = new Font(fontName, (int) fontSize);
if(!font.getName().toLowerCase().contains(fontName.toLowerCase())) {
String options = "";
for(String name : javafx.scene.text.Font.getFontNames() ) {
options+=name+"\n";
}
new Exception(options).printStackTrace();
}
ArrayList<CSG> tmp = TextExtrude.text( depth, text, font);
letters.clear();
for (int i=0;i<tmp.size();i++){
letters.add( tmp.get(i)
.rotx(180)
.toZMin()
);
}


List<CSG> tmp = TextExtrude.text(depth, text, font);
letters.clear();
for (int i = 0; i < tmp.size(); i++) {
letters.add(tmp.get(i)
.rotx(180)
.toZMin()
);
}
}

@Override
public List<Polygon> toPolygons() {
List<Polygon> poly =new ArrayList<Polygon>();
for(CSG c:letters) {
poly.addAll(c.getPolygons());
}
return poly;
List<Polygon> poly = new ArrayList<>();
for (CSG c : letters) {
poly.addAll(c.getPolygons());
}
return poly;
}

@Override
Expand Down
Loading
Loading