Skip to content

Commit

Permalink
features from old local version
Browse files Browse the repository at this point in the history
  • Loading branch information
chompa111 committed Oct 24, 2022
1 parent d3472f5 commit 4c3a6b7
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 17 deletions.
21 changes: 17 additions & 4 deletions src/main/java/graphical/basics/gobject/Line.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,34 @@ public class Line extends FillAndStroke implements ShapeLike {
Location p2;
ColorHolder colorHolder;

Line2D.Double line2D;

public Line(Location p1, Location p2, Color color, NumberHolder thickness) {
super(color,color);
super(color, color);
this.p1 = p1;
this.p2 = p2;
this.line2D = new Line2D.Double(p1.getX(), p1.getY(), p2.getX(), p2.getY());
this.colorHolder = new ColorHolder(color);
setStrokeThickness(thickness);
}

public Line(Location p1, Location p2, Color color) {
super(color,color);
super(color, color);
this.p1 = p1;
this.p2 = p2;
this.line2D = new Line2D.Double(p1.getX(), p1.getY(), p2.getX(), p2.getY());
this.colorHolder = new ColorHolder(color);
}


@Override
public void paint(Graphics g) {

line2D.setLine(p1.getX(), p1.getY(), p2.getX(), p2.getY());
Graphics2D g2 = (Graphics2D) g;
g2.setStroke(new BasicStroke((float)getStrokeThickness().getValue()));
g2.setStroke(new BasicStroke((float) getStrokeThickness().getValue()));
g.setColor(colorHolder.getColor());
g.drawLine((int) p1.getX(), (int) p1.getY(), (int) p2.getX(), (int) p2.getY());
g2.draw(line2D);
g2.setStroke(new BasicStroke(1));

}
Expand Down Expand Up @@ -87,4 +93,11 @@ public Location getP1() {
public Location getP2() {
return p2;
}

@Override
public Gobject copy() {
var copy = new Line(p1.copy(), p2.copy(), colorHolder.getColor());
copyBasicFields(copy, this);
return copy;
}
}
5 changes: 5 additions & 0 deletions src/main/java/graphical/basics/gobject/latex/Latex.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ public static Group of(String s) {
return new Group(generateExp(s, Location.at(0, 0), Color.white));
}

public static Group of(String s, double size) {
return new Group(generateExp(s, Location.at(0, 0), Color.white, size));
}

private static final double FONT_SIZE = 50;

public static List<Gobject> generateExp(String s, Location location, Color color) {
return generateExp(s, location, color, FONT_SIZE);
}


public static List<Gobject> generateExp(String s, Location location, Color color, double size) {

final var formula = new TeXFormula(s);
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/graphical/basics/gobject/latex/Rect.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import graphical.basics.ColorHolder;
import graphical.basics.gobject.shape.ShapeLike;
import graphical.basics.gobject.struct.FillAndStroke;
import graphical.basics.gobject.struct.Gobject;
import graphical.basics.location.Location;
import graphical.basics.location.LocationPair;

Expand Down Expand Up @@ -76,9 +77,17 @@ private double getCurrentHeight() {
return lowerRightPoint.getY() - upperLeftPoint.getY();
}

public Location getUpperLeftPoint() { return upperLeftPoint; }
public Location getUpperLeftPoint() {
return upperLeftPoint;
}

public Location getLowerRightPoint() {
return lowerRightPoint;
}


public static Rect backgroundFor(Gobject g, double margin) {
var borders = g.getBorders();
return new Rect(borders.getL1().plus(-margin, -margin), borders.getL2().plus(margin, margin), new Color(0,0,0,170));
}
}
15 changes: 13 additions & 2 deletions src/main/java/graphical/basics/gobject/struct/Gobject.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package graphical.basics.gobject.struct;


import graphical.basics.gobject.Group;
import graphical.basics.presentation.Positioning;
import graphical.basics.presentation.Presentation;
import graphical.basics.ColorHolder;
Expand All @@ -18,6 +19,8 @@

import java.awt.*;
import java.awt.geom.AffineTransform;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static graphical.basics.presentation.Positioning.Reference.*;
Expand Down Expand Up @@ -207,12 +210,20 @@ public double getHeight() {
return getBorders().getheight();
}

public Gobject copy(){
public Gobject copy() {
throw new RuntimeException("not implemented yet");
}
protected void copyBasicFields(Gobject copy, Gobject source){

protected void copyBasicFields(Gobject copy, Gobject source) {
copy.getScale().setValue(source.getScale().getValue());
copy.getAngle().setValue(source.getAngle().getValue());
}

public Group and(Gobject... gobjects) {
var result = new ArrayList<Gobject>();
result.add(this);
result.addAll(Arrays.asList(gobjects));
return new Group(result);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public static ShapeGobject2 fromSVGStyle(Shape shape, String style) {
@Override
public Gobject copy() {
var copy = new ShapeGobject2(ShapeCopyMachine.clone(shape),location.copy(), new ColorHolder(getFillColorHolder().getColor()), null);
copy.shapeOfsetX=this.shapeOfsetX;
copy.shapeOfsetY=this.shapeOfsetY;
copyBasicFields(copy, this);
return copy;
}
Expand Down
29 changes: 22 additions & 7 deletions src/main/java/graphical/basics/presentation/Animation.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import graphical.basics.ColorHolder;
import graphical.basics.gobject.Group;
import graphical.basics.gobject.Line;
import graphical.basics.gobject.latex.Rect;
import graphical.basics.gobject.shape.ShapeLike;
import graphical.basics.gobject.struct.*;
import graphical.basics.presentation.effects.T3b1b;
Expand All @@ -17,8 +18,6 @@
public class Animation {




private static final Presentation presentation = Presentation.staticReference;

public static Task fadeOut(Gobject gobject, int steps) {
Expand Down Expand Up @@ -121,6 +120,15 @@ public static Task fadeInGrow(Gobject gobject, int steps) {
});
}

public static Task fadeInGrowFromBig(Gobject gobject, int steps) {
return new ContextSetupTask(() -> {
var scale = gobject.scale.getValue();
gobject.getScale().setValue(15);
return fadeIn(gobject, steps).parallel(gobject.getScale().changeTo(scale, steps));
});
}


public static Task fadeoutGrow(Gobject gobject, int steps) {
return fadeOut(gobject, steps).parallel(gobject.getScale().change(gobject.getScale().getValue() * -1, steps));
}
Expand Down Expand Up @@ -200,11 +208,18 @@ public static Task clipInit(Gobject gobject) {
})).parallel(fadeIn(gobject));
}

public static Task replace(Gobject replaced,Gobject newGObject){
return new ContextSetupTask(()->{
newGObject.setPositionTo(replaced.getMidPoint());
return t3b1b(replaced,newGObject,presentation.seconds(1));
});
public static Task replace(Gobject replaced, Gobject newGObject) {
return new ContextSetupTask(() -> {
newGObject.setPositionTo(replaced.getMidPoint());
return t3b1b(replaced, newGObject, presentation.seconds(1));
});
}

public static Task emphasizeBox(Gobject g) {
var rect = Rect.backgroundFor(g, 15);
rect.setStrokeColorHolder(new ColorHolder(Color.orange));
rect.setFillColorHolder(new ColorHolder(new Color(0, 0, 0, 0)));
return strokeAndFill(rect, presentation.seconds(1));
}

}
6 changes: 3 additions & 3 deletions src/main/java/graphical/basics/presentation/Positioning.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ public static Task alignAll(List<Gobject> l1, List<Gobject> l2) {

for (int i = 0; i < l1.size(); i++) {
if(l1.get(i) instanceof Char2){
var char1=(Char2)l1.get(i);
var char2=(Char2)l2.get(i);
var char1=l1.get(i);
var char2=l2.get(i);

double ration=(char2.getSize()+0.0)/(char1.getSize()+0.0);
double ration=(char2.getWidth()+0.0)/(char1.getWidth()+0.0);
taskList.add(Positioning.animation.align(l1.get(i), l2.get(i), CENTER).parallel(char1.scale(ration)));
}else{

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/graphical/basics/presentation/Presentation.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static javax.swing.WindowConstants.EXIT_ON_CLOSE;
Expand Down Expand Up @@ -249,6 +250,9 @@ public void runBehaviors() {
public void add(Gobject gobject) {
gobjects.add(gobject);
}
public void add(Gobject... gs){
gobjects.addAll(Arrays.asList(gs));
}

public void addBefore(Gobject referential, Gobject gobject) {
gobjects.add(gobjects.indexOf(referential), gobject);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/graphical/basics/task/InterruptableTask.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package graphical.basics.task;

import graphical.basics.presentation.Presentation;

public class InterruptableTask implements Task {

private final Task slave;
Expand Down

0 comments on commit 4c3a6b7

Please sign in to comment.