JavaFX image library similar to Picasso or Glide Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Failed to load the JNI shared Library (JDK)Picasso v/s Imageloader v/s Fresco vs GlideGetting black ImageView using Picasso and GlidePicasso loads wrong imagesDraw bitmap on canvas with PicassoGlide Cache does not persist when app is killedGlide Android Image library is replacing semicolon with %3B in my URLBlur Image using PicassoHow to load URL into ImageView in a Android Wear Standalone App?Can't get Picasso to work due to some errors
Is accepting an invalid credit card number a security issue?
Suing a Police Officer Instead of the Police Department
Is Diceware more secure than a long passphrase?
What is the ongoing value of the Kanban board to the developers as opposed to management
"Rubric" as meaning "signature" or "personal mark" -- is this accepted usage?
Book with legacy programming code on a space ship that the main character hacks to escape
Do you need a weapon for Thunderous Smite, and the other 'Smite' spells?
How to not starve gigantic beasts
My admission is revoked after accepting the admission offer
Multiple fireplaces in an apartment building?
Expansion//Explosion and Siren Stormtamer
Are these square matrices always diagonalisable?
With indentation set to `0em`, when using a line break, there is still an indentation of a size of a space
Raising a bilingual kid. When should we introduce the majority language?
Why is this method for solving linear equations systems using determinants works?
As an international instructor, should I openly talk about my accent?
What do you call the part of a novel that is not dialog?
Co-worker works way more than he should
The art of proof summarizing. Are there known rules, or is it a purely common sense matter?
Married in secret, can marital status in passport be changed at a later date?
What's the difference between using dependency injection with a container and using a service locator?
What is /etc/mtab in Linux?
Align column where each cell has two decimals with siunitx
c++ diamond problem - How to call base method only once
JavaFX image library similar to Picasso or Glide
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Failed to load the JNI shared Library (JDK)Picasso v/s Imageloader v/s Fresco vs GlideGetting black ImageView using Picasso and GlidePicasso loads wrong imagesDraw bitmap on canvas with PicassoGlide Cache does not persist when app is killedGlide Android Image library is replacing semicolon with %3B in my URLBlur Image using PicassoHow to load URL into ImageView in a Android Wear Standalone App?Can't get Picasso to work due to some errors
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm looking for a library that allows me to load images in the same way as Picasso or Glide for Android/Java, I'm working in a desktop application using JavaFX 2 and image loading is clogging the main thread. I thought about creating a custom functionality from scratch, but I suppose they are a mature set of tool to avoid extra work. I had tried to load the image inside its thread, but it is not working.
@Override
public void initialize(URL url, ResourceBundle resourceBundle)
final String thumbnail = data.getSong().getThumbnail();
Runnable runnable = () ->
Image image = new Image(thumbnail);
imageView.setImage(image);
;
runnable.run();
java caching javafx picasso glade
add a comment |
I'm looking for a library that allows me to load images in the same way as Picasso or Glide for Android/Java, I'm working in a desktop application using JavaFX 2 and image loading is clogging the main thread. I thought about creating a custom functionality from scratch, but I suppose they are a mature set of tool to avoid extra work. I had tried to load the image inside its thread, but it is not working.
@Override
public void initialize(URL url, ResourceBundle resourceBundle)
final String thumbnail = data.getSong().getThumbnail();
Runnable runnable = () ->
Image image = new Image(thumbnail);
imageView.setImage(image);
;
runnable.run();
java caching javafx picasso glade
1
CallingRunnable.run()executes the code on the calling thread; you'd need to actually pass it to another thread either directly, withnew Thread(...).start(), or indirectly via a thread pool, such as anExecutorService. Have you tried using the load-in-background functionality ofImage?
– Slaw
Mar 9 at 5:57
add a comment |
I'm looking for a library that allows me to load images in the same way as Picasso or Glide for Android/Java, I'm working in a desktop application using JavaFX 2 and image loading is clogging the main thread. I thought about creating a custom functionality from scratch, but I suppose they are a mature set of tool to avoid extra work. I had tried to load the image inside its thread, but it is not working.
@Override
public void initialize(URL url, ResourceBundle resourceBundle)
final String thumbnail = data.getSong().getThumbnail();
Runnable runnable = () ->
Image image = new Image(thumbnail);
imageView.setImage(image);
;
runnable.run();
java caching javafx picasso glade
I'm looking for a library that allows me to load images in the same way as Picasso or Glide for Android/Java, I'm working in a desktop application using JavaFX 2 and image loading is clogging the main thread. I thought about creating a custom functionality from scratch, but I suppose they are a mature set of tool to avoid extra work. I had tried to load the image inside its thread, but it is not working.
@Override
public void initialize(URL url, ResourceBundle resourceBundle)
final String thumbnail = data.getSong().getThumbnail();
Runnable runnable = () ->
Image image = new Image(thumbnail);
imageView.setImage(image);
;
runnable.run();
java caching javafx picasso glade
java caching javafx picasso glade
asked Mar 9 at 5:49
Diego RestrepoDiego Restrepo
287
287
1
CallingRunnable.run()executes the code on the calling thread; you'd need to actually pass it to another thread either directly, withnew Thread(...).start(), or indirectly via a thread pool, such as anExecutorService. Have you tried using the load-in-background functionality ofImage?
– Slaw
Mar 9 at 5:57
add a comment |
1
CallingRunnable.run()executes the code on the calling thread; you'd need to actually pass it to another thread either directly, withnew Thread(...).start(), or indirectly via a thread pool, such as anExecutorService. Have you tried using the load-in-background functionality ofImage?
– Slaw
Mar 9 at 5:57
1
1
Calling
Runnable.run() executes the code on the calling thread; you'd need to actually pass it to another thread either directly, with new Thread(...).start(), or indirectly via a thread pool, such as an ExecutorService. Have you tried using the load-in-background functionality of Image?– Slaw
Mar 9 at 5:57
Calling
Runnable.run() executes the code on the calling thread; you'd need to actually pass it to another thread either directly, with new Thread(...).start(), or indirectly via a thread pool, such as an ExecutorService. Have you tried using the load-in-background functionality of Image?– Slaw
Mar 9 at 5:57
add a comment |
1 Answer
1
active
oldest
votes
For repetitive images image loading I would recommend using one of javafx animation tools.
PauseTransition is one option:
import javafx.animation.PauseTransition;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.util.Duration;
public class SlideShow extends Application
private static int counter =0;
private ImageView iv;
private Image[] images;
private Button swapImage;
private final String[] urls =
"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/lg/57/tropical-fish_1f420.png",
"https://www.shareicon.net/data/128x128/2015/03/28/14104_animal_256x256.png",
"https://cdn1.iconfinder.com/data/icons/DarkGlass_Reworked/128x128/apps/gnome-fish.png",
"http://www.iconsalot.com/asset/icons/freepik/pet-shop-13/128/010-fish-2-icon.png"
;
@Override
public void start(Stage primaryStage) throws Exception
images = new Image[urls.length];
for(int i=0; i< urls.length; i++)
images[i] = new Image(urls[i], true);
iv = new ImageView(images[counter++]);
swapImage = new Button("Start");
swapImage.setOnAction(e->update());
BorderPane root = new BorderPane(iv);
root.setBottom(new StackPane(swapImage));
Scene scene = new Scene(root,200,200);
primaryStage.setScene(scene);
primaryStage.show();
private void update()
swapImage.setDisable(true);
PauseTransition pause = new PauseTransition(Duration.seconds(1));
pause.setOnFinished(event ->
swapImage();
pause.play();
);
pause.play();
private void swapImage()
counter = counter % images.length;
iv.setImage(images[counter++]);
public static void main(String[] args)
Application.launch(args);
Alternatively you could use Timeline by modifying update() :
private void update()
swapImage.setDisable(true);
KeyFrame keyFrame = new KeyFrame(
Duration.seconds(1),
event -> swapImage()
);
Timeline timeline = new Timeline();
timeline.setCycleCount(Animation.INDEFINITE);
timeline.getKeyFrames().add(keyFrame);
timeline.play();
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55074411%2fjavafx-image-library-similar-to-picasso-or-glide%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
For repetitive images image loading I would recommend using one of javafx animation tools.
PauseTransition is one option:
import javafx.animation.PauseTransition;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.util.Duration;
public class SlideShow extends Application
private static int counter =0;
private ImageView iv;
private Image[] images;
private Button swapImage;
private final String[] urls =
"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/lg/57/tropical-fish_1f420.png",
"https://www.shareicon.net/data/128x128/2015/03/28/14104_animal_256x256.png",
"https://cdn1.iconfinder.com/data/icons/DarkGlass_Reworked/128x128/apps/gnome-fish.png",
"http://www.iconsalot.com/asset/icons/freepik/pet-shop-13/128/010-fish-2-icon.png"
;
@Override
public void start(Stage primaryStage) throws Exception
images = new Image[urls.length];
for(int i=0; i< urls.length; i++)
images[i] = new Image(urls[i], true);
iv = new ImageView(images[counter++]);
swapImage = new Button("Start");
swapImage.setOnAction(e->update());
BorderPane root = new BorderPane(iv);
root.setBottom(new StackPane(swapImage));
Scene scene = new Scene(root,200,200);
primaryStage.setScene(scene);
primaryStage.show();
private void update()
swapImage.setDisable(true);
PauseTransition pause = new PauseTransition(Duration.seconds(1));
pause.setOnFinished(event ->
swapImage();
pause.play();
);
pause.play();
private void swapImage()
counter = counter % images.length;
iv.setImage(images[counter++]);
public static void main(String[] args)
Application.launch(args);
Alternatively you could use Timeline by modifying update() :
private void update()
swapImage.setDisable(true);
KeyFrame keyFrame = new KeyFrame(
Duration.seconds(1),
event -> swapImage()
);
Timeline timeline = new Timeline();
timeline.setCycleCount(Animation.INDEFINITE);
timeline.getKeyFrames().add(keyFrame);
timeline.play();
add a comment |
For repetitive images image loading I would recommend using one of javafx animation tools.
PauseTransition is one option:
import javafx.animation.PauseTransition;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.util.Duration;
public class SlideShow extends Application
private static int counter =0;
private ImageView iv;
private Image[] images;
private Button swapImage;
private final String[] urls =
"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/lg/57/tropical-fish_1f420.png",
"https://www.shareicon.net/data/128x128/2015/03/28/14104_animal_256x256.png",
"https://cdn1.iconfinder.com/data/icons/DarkGlass_Reworked/128x128/apps/gnome-fish.png",
"http://www.iconsalot.com/asset/icons/freepik/pet-shop-13/128/010-fish-2-icon.png"
;
@Override
public void start(Stage primaryStage) throws Exception
images = new Image[urls.length];
for(int i=0; i< urls.length; i++)
images[i] = new Image(urls[i], true);
iv = new ImageView(images[counter++]);
swapImage = new Button("Start");
swapImage.setOnAction(e->update());
BorderPane root = new BorderPane(iv);
root.setBottom(new StackPane(swapImage));
Scene scene = new Scene(root,200,200);
primaryStage.setScene(scene);
primaryStage.show();
private void update()
swapImage.setDisable(true);
PauseTransition pause = new PauseTransition(Duration.seconds(1));
pause.setOnFinished(event ->
swapImage();
pause.play();
);
pause.play();
private void swapImage()
counter = counter % images.length;
iv.setImage(images[counter++]);
public static void main(String[] args)
Application.launch(args);
Alternatively you could use Timeline by modifying update() :
private void update()
swapImage.setDisable(true);
KeyFrame keyFrame = new KeyFrame(
Duration.seconds(1),
event -> swapImage()
);
Timeline timeline = new Timeline();
timeline.setCycleCount(Animation.INDEFINITE);
timeline.getKeyFrames().add(keyFrame);
timeline.play();
add a comment |
For repetitive images image loading I would recommend using one of javafx animation tools.
PauseTransition is one option:
import javafx.animation.PauseTransition;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.util.Duration;
public class SlideShow extends Application
private static int counter =0;
private ImageView iv;
private Image[] images;
private Button swapImage;
private final String[] urls =
"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/lg/57/tropical-fish_1f420.png",
"https://www.shareicon.net/data/128x128/2015/03/28/14104_animal_256x256.png",
"https://cdn1.iconfinder.com/data/icons/DarkGlass_Reworked/128x128/apps/gnome-fish.png",
"http://www.iconsalot.com/asset/icons/freepik/pet-shop-13/128/010-fish-2-icon.png"
;
@Override
public void start(Stage primaryStage) throws Exception
images = new Image[urls.length];
for(int i=0; i< urls.length; i++)
images[i] = new Image(urls[i], true);
iv = new ImageView(images[counter++]);
swapImage = new Button("Start");
swapImage.setOnAction(e->update());
BorderPane root = new BorderPane(iv);
root.setBottom(new StackPane(swapImage));
Scene scene = new Scene(root,200,200);
primaryStage.setScene(scene);
primaryStage.show();
private void update()
swapImage.setDisable(true);
PauseTransition pause = new PauseTransition(Duration.seconds(1));
pause.setOnFinished(event ->
swapImage();
pause.play();
);
pause.play();
private void swapImage()
counter = counter % images.length;
iv.setImage(images[counter++]);
public static void main(String[] args)
Application.launch(args);
Alternatively you could use Timeline by modifying update() :
private void update()
swapImage.setDisable(true);
KeyFrame keyFrame = new KeyFrame(
Duration.seconds(1),
event -> swapImage()
);
Timeline timeline = new Timeline();
timeline.setCycleCount(Animation.INDEFINITE);
timeline.getKeyFrames().add(keyFrame);
timeline.play();
For repetitive images image loading I would recommend using one of javafx animation tools.
PauseTransition is one option:
import javafx.animation.PauseTransition;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.util.Duration;
public class SlideShow extends Application
private static int counter =0;
private ImageView iv;
private Image[] images;
private Button swapImage;
private final String[] urls =
"https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/lg/57/tropical-fish_1f420.png",
"https://www.shareicon.net/data/128x128/2015/03/28/14104_animal_256x256.png",
"https://cdn1.iconfinder.com/data/icons/DarkGlass_Reworked/128x128/apps/gnome-fish.png",
"http://www.iconsalot.com/asset/icons/freepik/pet-shop-13/128/010-fish-2-icon.png"
;
@Override
public void start(Stage primaryStage) throws Exception
images = new Image[urls.length];
for(int i=0; i< urls.length; i++)
images[i] = new Image(urls[i], true);
iv = new ImageView(images[counter++]);
swapImage = new Button("Start");
swapImage.setOnAction(e->update());
BorderPane root = new BorderPane(iv);
root.setBottom(new StackPane(swapImage));
Scene scene = new Scene(root,200,200);
primaryStage.setScene(scene);
primaryStage.show();
private void update()
swapImage.setDisable(true);
PauseTransition pause = new PauseTransition(Duration.seconds(1));
pause.setOnFinished(event ->
swapImage();
pause.play();
);
pause.play();
private void swapImage()
counter = counter % images.length;
iv.setImage(images[counter++]);
public static void main(String[] args)
Application.launch(args);
Alternatively you could use Timeline by modifying update() :
private void update()
swapImage.setDisable(true);
KeyFrame keyFrame = new KeyFrame(
Duration.seconds(1),
event -> swapImage()
);
Timeline timeline = new Timeline();
timeline.setCycleCount(Animation.INDEFINITE);
timeline.getKeyFrames().add(keyFrame);
timeline.play();
answered Mar 9 at 15:17
c0derc0der
9,74651947
9,74651947
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55074411%2fjavafx-image-library-similar-to-picasso-or-glide%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Calling
Runnable.run()executes the code on the calling thread; you'd need to actually pass it to another thread either directly, withnew Thread(...).start(), or indirectly via a thread pool, such as anExecutorService. Have you tried using the load-in-background functionality ofImage?– Slaw
Mar 9 at 5:57