HiveBrain v1.2.0
Get Started
← Back to all entries
patternjavaMinor

Rotating Text in Circular Pattern Using JavaFX

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
rotatingjavafxtextcircularusingpattern

Problem

Just wanted to see what you all thought about my program, I basically have two different classes that I designed to allow for automated wrapping of text in a circular pattern. This is my first bit of useful and reusable code. Let me know what can be improved or added.

Here are some screenshots I took of the program in action:



Below is the main part of the program to let you see how it is used within the program:

```
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.effect.BlendMode;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;
import javafx.util.Duration;

/**
* Created by John on 7/17/2014.
*/
public class MouseEventDemo extends Application {
public double rotateImage;
Pane pane = new Pane();

@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
// Set pane's properties
pane.setStyle("-fx-background-color: black");

// Create and add objects
setMouseTrail();
setCenterObject();

// Create a scene and place it in the stage
Scene scene = new Scene(pane, 600, 600);
primaryStage.setTitle("MouseTrailDemo"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
}

/** Set mouse trail */
public void setMouseTrail() {
// Create image for cursor
ImageView imageView = new ImageView(new Image("/image/anon5.jpg"));
imageView.setBlendMode(BlendMode.SCREEN);
imageView.setCache(true);

Solution

from the book Clean Code


Long lists of imports are daunting to the reader. We don’t want to
clutter up the tops of our modules with 80 lines of imports.

I find this to be lot of imports too. But It's still somewhat OK,

import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.effect.BlendMode;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;
import javafx.util.Duration;


Use wildcards * to reduce number of imports If you think imports are cluttering the top of the class.

@Override // Override the start method in the Application class


This falls under too much information category.

/**
 * Created by John on 7/19/2014.
 */


Use the @author java-doc annotation to specify the author.

You do not need to specify the date of creation use Revision control instead.
Next thing you know is you will be writing a log up there.

Code Snippets

import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.effect.BlendMode;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;
import javafx.util.Duration;
@Override // Override the start method in the Application class
/**
 * Created by John on 7/19/2014.
 */

Context

StackExchange Code Review Q#57749, answer score: 5

Revisions (0)

No revisions yet.