Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8270319

Define an intermediate superclass for Transitions with a duration property

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10 Pro java 16

      A DESCRIPTION OF THE PROBLEM :
      There Are 8 simple animations that extend from the [Transition](https://openjfx.io/javadoc/16/javafx.graphics/javafx/animation/Transition.html) class

      1)[FillTransition](https://openjfx.io/javadoc/16/javafx.graphics/javafx/animation/FillTransition.html)
      2)[FadeTransition](https://openjfx.io/javadoc/16/javafx.graphics/javafx/animation/FadeTransition.html)
      3)[PathTransition](https://openjfx.io/javadoc/16/javafx.graphics/javafx/animation/PathTransition.html)
      4)[PauseTransition](https://openjfx.io/javadoc/16/javafx.graphics/javafx/animation/PauseTransition.html)
      5)[RotateTransition](https://openjfx.io/javadoc/16/javafx.graphics/javafx/animation/RotateTransition.html)
      6)[ScaleTransition](https://openjfx.io/javadoc/16/javafx.graphics/javafx/animation/ScaleTransition.html)
      7)[StrokeTransition](https://openjfx.io/javadoc/16/javafx.graphics/javafx/animation/StrokeTransition.html)
      8)[TranslateTransition](https://openjfx.io/javadoc/16/javafx.graphics/javafx/animation/TranslateTransition.html)

      All these transition animations have the [Duration Property](https://openjfx.io/javadoc/16/javafx.graphics/javafx/animation/TranslateTransition.html#durationProperty) in common and have the general
      ->setDuration(Duration)[https://openjfx.io/javadoc/16/javafx.graphics/javafx/animation/TranslateTransition.html#setDuration(javafx.util.Duration)]
      ->getDuration()[https://openjfx.io/javadoc/16/javafx.graphics/javafx/animation/TranslateTransition.html#getDuration()]
      methods in common but their definitions have been repeated in every class which has made me do very dirty checks for setting durations as follows

      if(animation instanceof TranslateTransition){((TranslateTransition)animation).setDuration(Duration.millis(duration));}
         else if(animation instanceof FillTransition){((FillTransition)animation).setDuration(Duration.millis(duration));}
         else if(animation instanceof FadeTransition){((FadeTransition)animation).setDuration(Duration.millis(duration));}
         else if(animation instanceof PathTransition){((PathTransition)animation).setDuration(Duration.millis(duration));}
         else if(animation instanceof PauseTransition){((PauseTransition)animation).setDuration(Duration.millis(duration));}
         else if(animation instanceof RotateTransition){((RotateTransition)animation).setDuration(Duration.millis(duration));}
         else if(animation instanceof ScaleTransition){((ScaleTransition)animation).setDuration(Duration.millis(duration));}
         else if(animation instanceof StrokeTransition){((StrokeTransition)animation).setDuration(Duration.millis(duration));}

      It would be very convenient if this property was moved to an seperate abstract class Say "TimedTransition" or something similar which extends from class Transition and then the above 8 classes extend from this class and make this class public for easy access


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: