/*
* File name: Arrows.java (package eas.users.lukas.arrows)
* Author(s): Lukas König
* Java version: 8.0 (at generation time)
* Generation date: 15.09.2014 (14:39:19)
*
* (c) This file and the EAS (Easy Agent Simulation) framework containing it
* is protected by Creative Commons by-nc-sa license. Any altered or
* further developed versions of this file have to meet the agreements
* stated by the license conditions.
*
* In a nutshell
* -------------
* You are free:
* - to Share -- to copy, distribute and transmit the work
* - to Remix -- to adapt the work
*
* Under the following conditions:
* - Attribution -- You must attribute the work in the manner specified by the
* author or licensor (but not in any way that suggests that they endorse
* you or your use of the work).
* - Noncommercial -- You may not use this work for commercial purposes.
* - Share Alike -- If you alter, transform, or build upon this work, you may
* distribute the resulting work only under the same or a similar license to
* this one.
*
* + Detailed license conditions (Germany):
* http://creativecommons.org/licenses/by-nc-sa/3.0/de/
* + Detailed license conditions (unported):
* http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en
*
* This header must be placed in the beginning of any version of this file.
*/
package eas.users.lukas.arrows;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import eas.math.geometry.Geometry2D;
import eas.math.geometry.Polygon2D;
import eas.math.geometry.Vector2D;
import eas.miscellaneous.StaticMethods;
import eas.startSetup.GlobalVariables;
import eas.startSetup.marbBuilder.zeichenModi.ArrowMaster;
import eas.startSetup.marbBuilder.zeichenModi.AusgMerkm;
import eas.startSetup.marbBuilder.zeichenModi.Pol2DMitAusgMerkm;
/**
* @author Lukas König
*/
public class Arrows {
public static void main(String[] args) {
ArrayList<Object> l = new ArrayList<Object>(1);
ArrayList<Double> dicken2;
Polygon2D bez2 = new Polygon2D();
double r1 = 190 * 1.9;
double r2 = 190 * 1.9;
Vector2D versch = new Vector2D(400, 500);
bez2.clear();
bez2.add(new Vector2D(1200, 500 + 190 * 1.9));
for (double i = 0.5 * Math.PI; i < 2 * Math.PI - 0.01; i += 0.001) {
Vector2D point = new Vector2D(r1 * Math.cos(i), r2 * Math.sin(i));
point.add(versch);
bez2.add(point);
r1 -= 0.004;
r2 -= 0.004;
}
bez2.add(new Vector2D(742, 580));
bez2 = bez2.normalize(GlobalVariables.getPrematureParameters());
dicken2 = new ArrayList<Double>(bez2.size());
int p1 = 2000;
int p2 = 330;
for (double i = 0; i < p1; i++) {
dicken2.add(50.0);
}
for (double i = p1; i < bez2.size() - p2; i++) {
dicken2.add(((i - p1 + 50) * Math.sqrt(i - p1 + 50)) / 500.0 + 50);
}
for (double i = bez2.size() - p2; i < bez2.size(); i++) {
dicken2.add((bez2.size() - i) / 2 + 125);
}
AusgMerkm[] strichelung = new AusgMerkm[] {
new AusgMerkm(Color.black, Color.white, true, false),
new AusgMerkm(Color.black, Color.white, true, true) };
Pol2DMitAusgMerkm[] pols = new ArrowMaster(GlobalVariables.getPrematureParameters())
.gestrichelterPfeil(
bez2,
dicken2,
ArrowMaster.EINFACHER_ABSCHLUSS,
ArrowMaster.KUGEL_ENDE,
new Vector2D(1, 1),
new Vector2D(0.45, 0.45),
strichelung,
4,
GlobalVariables.getPrematureParameters());
for (Pol2DMitAusgMerkm p : pols) {
if (p != null) {
l.add(p.getAusg());
l.add(p.getPol().toPol());
}
}
BufferedImage img = new BufferedImage(1500, 950, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = img.createGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, img.getWidth(), img.getHeight());
g.setColor(Color.black);
Geometry2D.maleObjListe(g, l);
StaticMethods.showImage(img, "test");
File outputfile = new File("C:/Users/Lukas König/Desktop/image.png");
try {ImageIO.write(img, "png", outputfile);} catch (IOException e) {}
}
public static Polygon2D getPolygon() {
ArrayList<Double> dicken2;
Polygon2D bez2 = new Polygon2D();
double r1 = 190 * 1.9;
double r2 = 190 * 1.9;
Vector2D versch = new Vector2D(400, 500);
bez2.clear();
bez2.add(new Vector2D(1200, 500 + 190 * 1.9));
for (double i = 0.5 * Math.PI; i < 2 * Math.PI - 0.01; i += 0.001) {
Vector2D point = new Vector2D(r1 * Math.cos(i), r2 * Math.sin(i));
point.add(versch);
bez2.add(point);
r1 -= 0.004;
r2 -= 0.004;
}
bez2.add(new Vector2D(742, 580));
bez2 = bez2.normalize(GlobalVariables.getPrematureParameters());
dicken2 = new ArrayList<Double>(bez2.size());
int p1 = 2000;
int p2 = 330;
for (double i = 0; i < p1; i++) {
dicken2.add(50.0);
}
for (double i = p1; i < bez2.size() - p2; i++) {
dicken2.add(((i - p1 + 50) * Math.sqrt(i - p1 + 50)) / 500.0 + 50);
}
for (double i = bez2.size() - p2; i < bez2.size(); i++) {
dicken2.add((bez2.size() - i) / 2 + 125);
}
Polygon2D pol =
new ArrowMaster(GlobalVariables.getPrematureParameters()).segmentPfeilPol2D(
bez2,
dicken2,
ArrowMaster.EINFACHER_ABSCHLUSS,
ArrowMaster.KUGEL_ENDE,
new Vector2D(1, 1),
new Vector2D(0.45, 0.45));
pol.rotate(pol.centerPoint(), Math.PI);
pol = pol.normalize(GlobalVariables.getPrematureParameters());
Polygon2D pol2 =
new ArrowMaster(GlobalVariables.getPrematureParameters()).segmentPfeilPol2D(
pol,
null,
ArrowMaster.EINFACHER_ABSCHLUSS,
ArrowMaster.EINFACHER_ABSCHLUSS,
new Vector2D(1, 1),
new Vector2D(1, 1));
for (int i = 0; i < pol2.size(); i += 2) {
pol2.remove(i);
}
for (int i = 0; i < pol2.size(); i += 2) {
pol2.remove(i);
}
for (int i = 0; i < pol2.size(); i += 2) {
pol2.remove(i);
}
for (int i = 0; i < pol2.size(); i += 2) {
pol2.remove(i);
}
for (int i = 0; i < pol2.size(); i += 2) {
pol2.remove(i);
}
for (int i = 0; i < pol2.size(); i += 2) {
pol2.remove(i);
}
for (int i = 0; i < pol2.size(); i += 2) {
pol2.remove(i);
}
return pol2;
}
}