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

Pagination controls buttons are not centered and missing the navigation arrows

    Details

      Description

      Pagination controls buttons are not centered and missing the navigation arrows

      package region;

      import java.lang.reflect.InvocationTargetException;
      import java.lang.reflect.Method;
      import java.util.ArrayList;
      import java.util.List;
      import javafx.application.Application;
      import javafx.beans.InvalidationListener;
      import javafx.beans.Observable;
      import javafx.geometry.Bounds;
      import javafx.geometry.Insets;
      import javafx.geometry.Pos;
      import javafx.scene.Node;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.control.Pagination;
      import javafx.scene.layout.Region;
      import javafx.scene.layout.VBox;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Rectangle;
      import javafx.scene.shape.StrokeType;
      import javafx.stage.Stage;
      import javafx.util.Callback;

      /**
       * User: richardbair Date: 8/22/12 Time: 9:42 AM
       */
      public class RegionUITestBase extends Application {
          @Override public void start(Stage stage) throws Exception {
              final List<Method> tests = new ArrayList<Method>();

              Class clazz = getClass();
              Method[] methods = clazz.getMethods();
              for (int i=0; i<methods.length; i++) {
                  Class<?>[] paramTypes = methods[i].getParameterTypes();
                  if (paramTypes.length == 1 && Region.class.isAssignableFrom(paramTypes[0])) {
                      tests.add(methods[i]);
                  }
              }

              final VBox parent = new VBox(5);
              parent.setAlignment(Pos.CENTER);
              parent.setFillWidth(false);
              parent.setPadding(new Insets(12));
              final Label label = new Label();
              label.setMinHeight(200);
              label.setWrapText(true);
              final Region region = new Region();
              region.setPrefSize(300, 300);
              final Rectangle boundsRect = new Rectangle();
              region.boundsInParentProperty().addListener(new InvalidationListener() {
                  @Override public void invalidated(Observable observable) {
                      Bounds bounds = region.getBoundsInParent();
                      boundsRect.setX(bounds.getMinX());
                      boundsRect.setY(bounds.getMinY());
                      boundsRect.setWidth(bounds.getWidth());
                      boundsRect.setHeight(bounds.getHeight());
                  }
              });
              boundsRect.setFill(null);
              boundsRect.setStroke(Color.BLACK);
              boundsRect.setStrokeType(StrokeType.OUTSIDE);
              boundsRect.setManaged(false);
              parent.getChildren().addAll(label, region, boundsRect);

              // I'm going to use a Pagination control to implement my multiple
              // test test!
              Pagination pagination = new Pagination(tests.size());
              pagination.setPageFactory(new Callback<Integer, Node>() {
                  @Override public Node call(Integer param) {
                      // We're going to reuse the same child every time. I wonder if this works?
                      Method test = tests.get(param);
                      try {
                          test.invoke(RegionUITestBase.this, region);
                      } catch (IllegalAccessException e) {
                          e.printStackTrace();
                      } catch (InvocationTargetException e) {
                          e.printStackTrace();
                      }
                      label.setText("Test: " + test.getName() + "\nStyle=" + (region.getStyle().replace(";", ";\n\t")));
                      return parent;
                  }
              });

              Scene scene = new Scene(pagination);
              stage.setScene(scene);
              stage.show();
          }

          public static void main(String[] args) {
              launch(args);
          }

          public void testBasicFill(Region region) {
              region.setStyle("-fx-background-color: red;");
          }

          public void testNegativeInsets(Region region) {
              region.setStyle(
                      "-fx-background-color: red;" +
                      "-fx-background-insets: 0 0 -10 0");
          }

          public void testNegativeInsets2(Region region) {
              region.setStyle(
                      "-fx-background-color: red;" +
                      "-fx-background-insets: -5 -7 -9 -11");
          }

          public void testInsets1(Region region) {
              region.setStyle(
                      "-fx-background-color: red;" +
                      "-fx-background-insets: 5");
          }

          public void testInsets2(Region region) {
              region.setStyle(
                      "-fx-background-color: red;" +
                      "-fx-background-insets: 5 10");
          }

          public void testInsets3(Region region) {
              region.setStyle(
                      "-fx-background-color: red;" +
                      "-fx-background-insets: 5 10 15");
          }

          public void testInsets4(Region region) {
              region.setStyle(
                      "-fx-background-color: red;" +
                      "-fx-background-insets: 5 10 15 20");
          }

          public void testScenario1(Region region) {
              region.setStyle(
                      "-fx-background-color: red;" +
                      "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" +
                      "-fx-background-radius: 10 20 30 40;" +
                      "-fx-padding: 10 20 30 40;");
          }

          public void testScenario2(Region region) {
              region.setStyle(
                      "-fx-background-color: red, green, blue, yellow;" +
                      "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" +
                      "-fx-background-radius: 5 10 15 20, 25, 30 35 40 45;" +
                      "-fx-padding: 10 20 30 40;");
          }

          public void testScenario3(Region region) {
              region.setStyle(
                      "-fx-background-color: red, green, blue, yellow;" +
                      "-fx-background-insets: 0 0 -10 0, 0, 10, 20;" +
                      "-fx-background-radius: 10 20 30 40;" +
                      "-fx-padding: 10 20 30 40;");
          }

          public void testExample1(Region region) {
              region.setStyle(
                      "-fx-background-color: red, green, blue;" +
                      "-fx-background-insets: 4, 8, 12, 16;" + // An extra value here, which should be ignored
                      "-fx-background-radius: 4;");
          }
      }

        Attachments

          Activity

            People

            • Assignee:
              kwwong Kinsley Wong
              Reporter:
              kwwong Kinsley Wong
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: