Skip to content

Commit

Permalink
presentation refactor and slide primary struct
Browse files Browse the repository at this point in the history
  • Loading branch information
chompa111 committed May 30, 2023
1 parent 61ceb9d commit 011301d
Show file tree
Hide file tree
Showing 26 changed files with 775 additions and 598 deletions.
4 changes: 2 additions & 2 deletions src/main/java/graphical/basics/ColorHolder.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package graphical.basics;


import graphical.basics.presentation.Presentation;
import graphical.basics.presentation.Animation;
import graphical.basics.task.Task;
import graphical.basics.task.transformation.gobject.ColorListTranform;

Expand Down Expand Up @@ -45,7 +45,7 @@ public ColorHolder copy() {
}

public Task changeColor(Color c) {
return changeColor(c, Presentation.staticReference.seconds(1));
return changeColor(c, Animation.staticReference.seconds(1));
}

public Task changeColor(Color color, int steps) {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/graphical/basics/DecodeAndCaptureFrames.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ public class DecodeAndCaptureFrames extends MediaListenerAdapter {
private int mVideoStreamIndex = -1;
BufferedImage bu;
IMediaReader reader;
String videoFile;

boolean pepe = false;


public DecodeAndCaptureFrames(String videoFile) {
this.videoFile = videoFile;
config();
}

public void config() {
bu = null;
// create a media reader for processing video
reader = ToolFactory.makeReader(videoFile);

Expand All @@ -29,6 +36,10 @@ public DecodeAndCaptureFrames(String videoFile) {
// onVideoPicture().

reader.addListener(this);

while (getFrame() == null) {
processFrame();
}
}

public void processFrame() {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/graphical/basics/behaviors/AlwaysOnTop.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package graphical.basics.behaviors;

import graphical.basics.gobject.struct.Gobject;
import graphical.basics.presentation.Presentation;
import graphical.basics.presentation.Animation;

public class AlwaysOnTop {

public static Runnable onTop(Gobject gobject) {
return () ->{
Presentation.staticReference.remove(gobject);
Presentation.staticReference.add(gobject);
Animation.staticReference.remove(gobject);
Animation.staticReference.add(gobject);
};
}
}
40 changes: 20 additions & 20 deletions src/main/java/graphical/basics/gobject/AnimPart.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,86 +2,86 @@

import graphical.basics.BackGround;
import graphical.basics.gobject.struct.Gobject;
import graphical.basics.presentation.Presentation;
import graphical.basics.presentation.Animation;
import graphical.basics.presentation.PresentationConfig;
import graphical.basics.task.Task;

public abstract class AnimPart {
protected abstract void buildPresentation(Gobject... gobjects);

public void add(Gobject gobject) {
Presentation.staticReference.add(gobject);
Animation.staticReference.add(gobject);
}

public void add(Gobject... gs) {
Presentation.staticReference.add(gs);
Animation.staticReference.add(gs);
}

public void addBefore(Gobject referential, Gobject gobject) {
Presentation.staticReference.addBefore(referential, gobject);
Animation.staticReference.addBefore(referential, gobject);
}

public void remove(Gobject gobject) {
Presentation.staticReference.remove(gobject);
Animation.staticReference.remove(gobject);
}

public void remove(Gobject... gobjects) {
Presentation.staticReference.remove(gobjects);
Animation.staticReference.remove(gobjects);
}

public void removeAll() {
Presentation.staticReference.removeAll();
Animation.staticReference.removeAll();
}

public void execute(Task task) {
Presentation.staticReference.execute(task);
Animation.staticReference.execute(task);
}

public void execute(Task... tasks) {
Presentation.staticReference.execute(tasks);
Animation.staticReference.execute(tasks);
}

public void cut() {
Presentation.staticReference.cut();
Animation.staticReference.cut();
}

public int seconds(double seconds) {
return Presentation.staticReference.seconds(seconds);
return Animation.staticReference.seconds(seconds);
}

public Task paralel(Task... tasks) {
return Presentation.staticReference.paralel(tasks);
return Animation.staticReference.paralel(tasks);
}

public Task fadeOut(Gobject gobject, int steps) {
return Presentation.staticReference.fadeOut(gobject, steps);
return Animation.staticReference.fadeOut(gobject, steps);
}

public Task fadeOut(Gobject gobject) {
return Presentation.staticReference.fadeOut(gobject);
return Animation.staticReference.fadeOut(gobject);
}

public Task wait(int steps) {
return Presentation.staticReference.wait(steps);
return Animation.staticReference.wait(steps);
}

public void switchOff() {
Presentation.staticReference.switchOff();
Animation.staticReference.switchOff();
}

public void switchOn() {
Presentation.staticReference.switchOn();
Animation.staticReference.switchOn();
}

public BackGround getBackGround() {
return Presentation.staticReference.getBackGround();
return Animation.staticReference.getBackGround();
}

public Camera getCamera() {
return Presentation.staticReference.getCamera();
return Animation.staticReference.getCamera();
}

public PresentationConfig getPresentationConfig() {
return Presentation.staticReference.getPresentationConfig();
return Animation.staticReference.getPresentationConfig();
}
}
14 changes: 7 additions & 7 deletions src/main/java/graphical/basics/gobject/CodeBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import graphical.basics.gobject.latex.Rect;
import graphical.basics.location.Location;
import graphical.basics.presentation.Animation;
import graphical.basics.presentation.Animations;
import graphical.basics.presentation.AnimationStaticReference;
import graphical.basics.presentation.Presentation;
import graphical.basics.presentation.Animation;
import graphical.basics.task.SupplierTask;
import graphical.basics.task.Task;
import graphical.basics.task.WaitTask;
Expand Down Expand Up @@ -101,7 +101,7 @@ public Task newLineAnimated(int index, String line) {
.parallel(backgroundShadow.getLowerRightPoint().move(0, textSize * 1.15, AnimationStaticReference.staticReference.seconds(1)))
.parallel(gutter.getLowerRightPoint().move(0, textSize * 1.15, AnimationStaticReference.staticReference.seconds(1)))
.parallel(gutterLine.getP2().move(0, textSize * 1.15, AnimationStaticReference.staticReference.seconds(1)))
.parallel(Animation.fadeInGrow(newNumber, AnimationStaticReference.staticReference.seconds(1)))
.parallel(Animations.fadeInGrow(newNumber, AnimationStaticReference.staticReference.seconds(1)))
.afterConclusion(() -> {
lineCounter++;
javaHilighter.colorize(text);
Expand Down Expand Up @@ -137,7 +137,7 @@ public Task removeLinesAnimated(int i, int j) {
.parallel(backgroundShadow.getLowerRightPoint().move(0, -(j-i+1)*textSize * 1.15, AnimationStaticReference.staticReference.seconds(1)))
.parallel(gutter.getLowerRightPoint().move(0, -(j-i+1)*textSize * 1.15, AnimationStaticReference.staticReference.seconds(1)))
.parallel(gutterLine.getP2().move(0, -(j-i+1)*textSize * 1.15, AnimationStaticReference.staticReference.seconds(1)))
.parallel(Animation.fadeoutGrow(textGutter.getLinesAsGroup((lineCounter-2)-(j-i),lineCounter-2), Presentation.staticReference.seconds(0.75)))
.parallel(Animations.fadeoutGrow(textGutter.getLinesAsGroup((lineCounter-2)-(j-i),lineCounter-2), Animation.staticReference.seconds(0.75)))
.afterConclusion(()->{
textGutter.removeLines((lineCounter-2)-(j-i),lineCounter-2);
lineCounter-=(j-i+1);
Expand All @@ -151,7 +151,7 @@ public Task removeLineAnimated(int index) {
.parallel(backgroundShadow.getLowerRightPoint().move(0, -textSize * 1.15, AnimationStaticReference.staticReference.seconds(1)))
.parallel(gutter.getLowerRightPoint().move(0, -textSize * 1.15, AnimationStaticReference.staticReference.seconds(1)))
.parallel(gutterLine.getP2().move(0, -textSize * 1.15, AnimationStaticReference.staticReference.seconds(1)))
.parallel(Animation.fadeOut(textGutter.getLine(lineCounter-2), AnimationStaticReference.staticReference.seconds(1)))
.parallel(Animations.fadeOut(textGutter.getLine(lineCounter-2), AnimationStaticReference.staticReference.seconds(1)))
.afterConclusion(()->{
textGutter.removeLine(lineCounter - 2);
lineCounter--;
Expand All @@ -166,12 +166,12 @@ public Task newLinesAnimated(int index, String... newLines) {
.parallel(backgroundShadow.getLowerRightPoint().move(0, amount * textSize * 1.15, AnimationStaticReference.staticReference.seconds(1)))
.parallel(gutter.getLowerRightPoint().move(0, amount * textSize * 1.15, AnimationStaticReference.staticReference.seconds(1)))
.parallel(gutterLine.getP2().move(0, amount * textSize * 1.15, AnimationStaticReference.staticReference.seconds(1)))
.parallel(new WaitTask(Presentation.staticReference.seconds(0.5) + 1)
.parallel(new WaitTask(Animation.staticReference.seconds(0.5) + 1)
.andThen(() -> {
for (int i = 0; i < newLines.length; i++) {
textGutter.newLine("" + (lineCounter + i));
}
return textGutter.getLinesAsGroup(lineCounter - 1, lineCounter - 2 + amount).onChildren(x -> Animation.fadeInGrow(x, AnimationStaticReference.staticReference.seconds(1)));
return textGutter.getLinesAsGroup(lineCounter - 1, lineCounter - 2 + amount).onChildren(x -> Animations.fadeInGrow(x, AnimationStaticReference.staticReference.seconds(1)));
}))
.afterConclusion(() -> {
lineCounter += amount;
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/graphical/basics/gobject/DynamicPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

import graphical.basics.ColorHolder;
import graphical.basics.gobject.struct.FillAndStroke;
import graphical.basics.gobject.struct.ShapeGobject2;
import graphical.basics.location.Location;
import graphical.basics.location.LocationPair;
import graphical.basics.location.Point;
import graphical.basics.presentation.Presentation;

import java.awt.*;
import java.awt.geom.Ellipse2D;
import java.awt.geom.FlatteningPathIterator;
import java.awt.geom.GeneralPath;
import java.awt.geom.PathIterator;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/graphical/basics/gobject/FrameSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import graphical.basics.gobject.struct.Gobject;
import graphical.basics.location.Location;
import graphical.basics.location.LocationPair;
import graphical.basics.presentation.Presentation;
import graphical.basics.presentation.Animation;
import graphical.basics.presentation.AnimationStaticReference;
import graphical.basics.task.SingleStepTask;
import graphical.basics.task.Task;

Expand All @@ -20,7 +21,7 @@ public class FrameSequence extends Gobject {


public FrameSequence(Location location,String path, int fps) {
fpsRatio = fps / (Presentation.staticReference.seconds(1) + 0.0);
fpsRatio = fps / (AnimationStaticReference.staticReference.seconds(1) + 0.0);
File folder = new File(path);
for (File file : folder.listFiles()) {
frames.add(new Image(location,file));
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/graphical/basics/gobject/GobjectFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import graphical.basics.gobject.struct.Gobject;
import graphical.basics.location.Location;
import graphical.basics.location.LocationPair;
import graphical.basics.presentation.Presentation;
import graphical.basics.presentation.Animation;
import graphical.basics.task.transformation.gobject.Pixel;

import java.awt.*;
Expand All @@ -23,8 +23,8 @@ public class GobjectFrame extends Gobject {

public GobjectFrame(Gobject gobject) {

int w = Presentation.staticReference.getPresentationConfig().getWidth();
int h = Presentation.staticReference.getPresentationConfig().getHeight();
int w = Animation.staticReference.getPresentationConfig().getWidth();
int h = Animation.staticReference.getPresentationConfig().getHeight();

bufferedImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
this.gobject = gobject;
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/graphical/basics/gobject/Magnifier.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package graphical.basics.gobject;

import graphical.basics.ColorHolder;
import graphical.basics.gobject.struct.ClipBox;
import graphical.basics.gobject.struct.Gobject;
import graphical.basics.location.Location;
import graphical.basics.location.LocationPair;
import graphical.basics.presentation.Presentation;
import graphical.basics.presentation.Animation;

import java.awt.*;
import java.awt.geom.AffineTransform;
Expand Down Expand Up @@ -73,7 +72,7 @@ public void paint(Graphics g) {



for (Gobject gobject : Presentation.staticReference.getGobjects()) {
for (Gobject gobject : Animation.staticReference.getGobjects()) {

if(gobject.equals(this)){
//avoiding recursion
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/graphical/basics/gobject/Presentation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package graphical.basics.gobject;

import graphical.basics.presentation.RTAnimation;

import java.awt.event.KeyEvent;
import java.util.ArrayList;

public abstract class Presentation extends RTAnimation {
ArrayList<SaturnSlide> slideSequence = new ArrayList<>();
int index = 0;


@Override
public void buildAnimation() {
addKeyPressedListener(x -> {
if (x.getKeyCode() == KeyEvent.VK_RIGHT) {
if (index < slideSequence.size() - 1) {
slideSequence.get(index).perform();
if (index > 0)
slideSequence.get(index - 1).remove();
index++;
}
}
});
addKeyPressedListener(x -> {
if (x.getKeyCode() == KeyEvent.VK_LEFT) {
if (index > 0) {
if (index > 1) {
slideSequence.get(index - 2).add();
slideSequence.get(index - 1).release();
index--;
}
}
}
});
}

public void addSlide(SaturnSlide saturnSlide) {
slideSequence.add(saturnSlide);
}
}
15 changes: 15 additions & 0 deletions src/main/java/graphical/basics/gobject/SaturnSlide.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package graphical.basics.gobject;

import graphical.basics.presentation.AnimationStaticReference;

public interface SaturnSlide {
void perform();

void revert();

void remove();

void add();

void release();
}
8 changes: 4 additions & 4 deletions src/main/java/graphical/basics/gobject/TextGobject.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import graphical.basics.gobject.struct.Gobject;
import graphical.basics.gobject.struct.ShapeGobject2;
import graphical.basics.location.Location;
import graphical.basics.presentation.Animations;
import graphical.basics.presentation.Animation;
import graphical.basics.presentation.Presentation;
import graphical.basics.task.Task;

import java.awt.*;
Expand Down Expand Up @@ -56,7 +56,7 @@ public static void indexsize(Group group) {
for (Gobject gobject : group.getGobjects()) {

var number = new TextGobject(new Font("Consolas", Font.BOLD, 15), index + "", gobject.getBorders().midPoint(), Color.green);
Presentation.staticReference.add(number);
Animation.staticReference.add(number);
index++;
}
}
Expand All @@ -81,9 +81,9 @@ public Shape toSingleShape() {
}

public Task write(){
return this.onChildren(Animation::strokeAndFill,3);
return this.onChildren(Animations::strokeAndFill,3);
}
public Task write(int frames, double delay){
return this.onChildren(c->Animation.strokeAndFill(c,frames),delay);
return this.onChildren(c-> Animations.strokeAndFill(c,frames),delay);
}
}
Loading

0 comments on commit 011301d

Please sign in to comment.