gwt.material.design.client.constants.Axis Java Examples

The following examples show how to use gwt.material.design.client.constants.Axis. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MaterialStepperTest.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
protected void checkAxis(MaterialStepper stepper) {
    MaterialStep step = stepper.getCurrentStep();

    step.setAxis(Axis.HORIZONTAL);
    assertEquals(step.getAxis(), Axis.HORIZONTAL);

    assertEquals(step.getHeader().getWidget(0), step.getDivCircle());
    assertEquals(step.getHeader().getWidget(1), step.getDivTitle());
    assertEquals(step.getHeader().getWidget(2), step.getDivDescription());
    assertEquals(step.getWidget(1), step.getDivLine());

    step.setAxis(Axis.VERTICAL);
    assertEquals(step.getAxis(), Axis.VERTICAL);

    assertEquals(step.getConBody().getWidget(0), step.getDivTitle());
    assertEquals(step.getConBody().getWidget(1), step.getDivDescription());
    assertEquals(step.getHeader().getWidget(1), step.getDivLine());
}
 
Example #2
Source File: StepperTransitionMixin.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
@Override
public void animatePrevious() {
    MaterialStep currentStep = stepper.getCurrentStep();
    MaterialStep previousStep = stepper.getStep(currentStep.getStep() - 1);
    if (currentStep != null && previousStep != null) {
        if (enableTransition && stepper.getAxis() == Axis.HORIZONTAL) {
            currentStep.getDivBody().setOverflow(Style.Overflow.HIDDEN);
            new MaterialAnimation().transition(previousOutTransition).animate(currentStep.getConBody(), () -> {
                currentStep.setActive(false);
                currentStep.getDivBody().setOverflow(Style.Overflow.AUTO);
            });

            previousStep.setActive(true);
            previousStep.getDivBody().setOverflow(Style.Overflow.HIDDEN);
            new MaterialAnimation().transition(previousInTransition).animate(previousStep.getConBody(), () -> {
                previousStep.getDivBody().setOverflow(Style.Overflow.AUTO);
            });
        } else {
            currentStep.setActive(false);
            previousStep.setActive(true);
        }
    }
}
 
Example #3
Source File: StepperTransitionMixin.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
@Override
public void animateNext() {
    MaterialStep currentStep = stepper.getCurrentStep();
    MaterialStep nextStep = stepper.getStep(currentStep.getStep() + 1);
    if (currentStep != null && nextStep != null) {

        if (enableTransition && stepper.getAxis() == Axis.HORIZONTAL) {
            currentStep.getDivBody().setOverflow(Style.Overflow.HIDDEN);
            new MaterialAnimation().transition(nextOutTransition).animate(currentStep.getConBody(), () -> {
                currentStep.setActive(false);
                currentStep.getDivBody().setOverflow(Style.Overflow.AUTO);
            });

            nextStep.setActive(true);
            new MaterialAnimation().transition(nextInTransition).animate(nextStep.getConBody());
        } else {
            currentStep.setActive(false);
            nextStep.setActive(true);
        }
    }
}
 
Example #4
Source File: MaterialStepper.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
@Override
public void setAxis(Axis axis) {
    getAxisMixin().setCssName(axis);
    for (int i = 0; i < getWidgetCount(); i++) {
        Widget w = getWidget(i);
        if (w instanceof MaterialStep) {
            ((MaterialStep) w).setAxis(axis);
        }
    }
}
 
Example #5
Source File: MaterialStepperTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
public void testStructure() {
    // UiBinder
    // given
    MaterialWidget stepper = getWidget();

    // when / then
    steps.forEach(step -> {
        int i = steps.indexOf(step) + 1;

        assertEquals(i, step.getStep());
        assertEquals(step.getWidget(0), step.getHeader());
        Div conCircle = step.getHeader();

        assertEquals(step.getWidget(1), step.getDivLine());
        Div conBody = step.getConBody();

        assertEquals(step.getAxis(), Axis.HORIZONTAL);
        assertEquals(step.getDivCircle(), conCircle.getWidget(0));
        assertEquals(step.getDivTitle(), conCircle.getWidget(1));
        assertEquals(step.getDivDescription(), conCircle.getWidget(2));

        step.setAxis(Axis.VERTICAL);
        assertEquals(step.getDivTitle(), conBody.getWidget(0));
        assertEquals(step.getDivDescription(), conBody.getWidget(1));
        assertEquals(step.getDivCircle(), conCircle.getWidget(0));
        assertEquals(step.getDivLine(), conCircle.getWidget(1));
    });

    assertEquals(stepper.getWidgetCount(), 5);
}
 
Example #6
Source File: MaterialSplitPanelTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
protected void checkProperties(MaterialSplitPanel splitPanel) {
    splitPanel.setBarPosition(20);
    assertEquals(0.2, splitPanel.getBarPosition());
    splitPanel.setLeftMin(10);
    assertEquals(Double.valueOf(10), splitPanel.getLeftMin());
    splitPanel.setLeftMax(40);
    assertEquals(Double.valueOf(40), splitPanel.getLeftMax());
    splitPanel.setBottomMax(20);
    assertEquals(Double.valueOf(20), splitPanel.getBottomMax());
    splitPanel.setBottomMin(30);
    assertEquals(Double.valueOf(30), splitPanel.getBottomMin());
    splitPanel.setTopMax(20);
    assertEquals(Double.valueOf(20), splitPanel.getTopMax());
    splitPanel.setTopMin(30);
    assertEquals(Double.valueOf(30), splitPanel.getTopMin());
    splitPanel.setRightMax(20);
    assertEquals(Double.valueOf(20), splitPanel.getRightMax());
    splitPanel.setRightMin(30);
    assertEquals(Double.valueOf(30), splitPanel.getRightMin());
    splitPanel.setDock(Dock.RIGHT);
    assertEquals(Dock.RIGHT, splitPanel.getDock());
    splitPanel.setDock(Dock.BOTTOM);
    assertEquals(Dock.BOTTOM, splitPanel.getDock());
    splitPanel.setDock(Dock.LEFT);
    assertEquals(Dock.LEFT, splitPanel.getDock());
    splitPanel.setDock(Dock.TOP);
    assertEquals(Dock.TOP, splitPanel.getDock());
    splitPanel.setAxis(Axis.HORIZONTAL);
    assertEquals(Axis.HORIZONTAL, splitPanel.getAxis());
    splitPanel.setAxis(Axis.VERTICAL);
    assertEquals(Axis.VERTICAL, splitPanel.getAxis());
    splitPanel.setThickness(200);
    assertEquals(Double.valueOf(200), splitPanel.getThickness());
}
 
Example #7
Source File: MaterialDndTest.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
protected void checkAxis(MaterialPanel panel) {
    final String VERTICAL_AXIS = "y";
    final String HORIZONTAL_AXIS = "x";
    MaterialDnd dnd = MaterialDnd.draggable(panel, JsDragOptions.create(Axis.VERTICAL));
    assertEquals(VERTICAL_AXIS, dnd.getDragOptions().axis);
    dnd.getDragOptions().axis = HORIZONTAL_AXIS;
    assertEquals(HORIZONTAL_AXIS, dnd.getDragOptions().axis);
}
 
Example #8
Source File: JsSplitPanelOptions.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
@JsOverlay
final static public JsSplitPanelOptions create() {
    JsSplitPanelOptions options = new JsSplitPanelOptions();
    options.thickness = "8px";
    options.barPosition = 0.5;
    options.dock = Dock.LEFT.getCssName();
    options.orientation = Axis.HORIZONTAL.getCssName();
    return options;
}
 
Example #9
Source File: MaterialStepper.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
protected void detectAndApplyOrientation() {
    if (getAxis() != null && getAxis() == Axis.VERTICAL && !Window.matchMedia(Resolution.ALL_MOBILE.asMediaQuery())) {
        return;
    }

    if (Window.matchMedia("(orientation: portrait)")) {
        setAxis(Axis.VERTICAL);
    } else {
        setAxis(Axis.HORIZONTAL);
    }
}
 
Example #10
Source File: JsDragOptions.java    From gwt-material-addins with Apache License 2.0 5 votes vote down vote up
@JsOverlay
public static JsDragOptions create(boolean inertia, Axis axis, Restriction restriction) {
    JsDragOptions options = new JsDragOptions();
    options.inertia = inertia;
    if (axis != null) {
        if (axis.equals(Axis.HORIZONTAL)) {
            options.axis = "x";
        } else {
            options.axis = "y";
        }
    }

    // Restrict Options
    JsDragRestrictions restrict = new JsDragRestrictions();
    if (restriction != null) {
        restrict.restriction = restriction.getRestriction();
        restrict.endOnly = restriction.isEndOnly();

        // Element Rec Options
        JsDragElementRect elementRect = new JsDragElementRect();
        elementRect.top = restriction.getTop();
        elementRect.left = restriction.getLeft();
        elementRect.bottom = restriction.getBottom();
        elementRect.right = restriction.getRight();
        restrict.elementRect = elementRect;
    }
    options.restrict = restrict;

    return options;
}
 
Example #11
Source File: JsDragOptions.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
@JsOverlay
public static JsDragOptions create(Axis axis) {
    return create(true, axis, new Restriction());
}
 
Example #12
Source File: DndView.java    From gwt-material-demo with Apache License 2.0 4 votes vote down vote up
@Inject
DndView(Binder uiBinder) {
    initWidget(uiBinder.createAndBindUi(this));

    MaterialDnd.draggable(panel);
    MaterialDnd.draggable(woInertialPanel, JsDragOptions.create(false));

    Restriction restriction = new Restriction();
    restriction.setEndOnly(false);
    MaterialDnd.draggable(endOnlyPanel, JsDragOptions.create(restriction));

    Restriction restriction1 = new Restriction();
    restriction1.setRestriction(Restriction.Restrict.SELF);
    MaterialDnd.draggable(selfRestrict, JsDragOptions.create(restriction1));

    Restriction restriction2 = new Restriction();
    restriction2.setTop(0.25);
    restriction2.setLeft(0.25);
    restriction2.setRight(0.75);
    restriction2.setBottom(0.75);
    MaterialDnd.draggable(restrictPanel, JsDragOptions.create(restriction2));

    MaterialDnd dndIgnore =  MaterialDnd.draggable(dndIgnoreFrom);
    dndIgnore.ignoreFrom(ignoredPanel);

    MaterialDnd.draggable(xAxisPanel, JsDragOptions.create(Axis.HORIZONTAL));
    MaterialDnd.draggable(yAxisPanel, JsDragOptions.create(Axis.VERTICAL));

    MaterialDnd.draggable(item1);
    MaterialDnd.draggable(item2);
    MaterialDnd.draggable(item3);
    MaterialDnd.draggable(item4);

    MaterialDnd.dropzone(dropzoneContainer, JsDropOptions.create(".test"));

    dropzoneContainer.addDropActivateHandler(event1 -> {
        MaterialToast.fireToast("Drop Activate");
    });

    dropzoneContainer.addDragEnterHandler(dragEnterEvent -> {
        placeContainer.setBackgroundColor(Color.BLUE);
        MaterialToast.fireToast("Drag Enter");
    });

    dropzoneContainer.addDragLeaveHandler(event1 -> {
        placeContainer.setBackgroundColor(Color.GREY_LIGHTEN_2);
        MaterialToast.fireToast("Drag Leave");
    });

    dropzoneContainer.addDropHandler(event -> {
        JQueryElement target = $(event.getRelatedTarget());
        MaterialWidget widget = new MaterialWidget(target.asElement());
        placeContainer.add(widget);
        MaterialToast.fireToast("Dropped");
    });

    dropzoneContainer.addDropDeactivateHandler(event -> {
        MaterialToast.fireToast("Drop Deactivate");
    });

    MaterialDnd.draggable(eventPanel);

    // Add Drag Start Handler
    eventPanel.addDragStartHandler(event -> {
        eventPanel.setBackgroundColor(Color.BLUE);
        lblStarted.setVisible(true);
    });
    // Add Drag Move Handler
    eventPanel.addDragMoveHandler(event -> {
        eventPanel.setBackgroundColor(Color.AMBER);
        lblMoved.setVisible(true);
    });
    // Add Drag End Handler
    eventPanel.addDragEndHandler(event -> {
        eventPanel.setBackgroundColor(Color.GREEN);
        lblEnded.setVisible(true);
    });
}
 
Example #13
Source File: MaterialStepper.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
@Override
public Axis getAxis() {
    return getAxisMixin().getCssName();
}
 
Example #14
Source File: MaterialStepper.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
protected CssNameMixin<MaterialStepper, Axis> getAxisMixin() {
    if (axisMixin == null) {
        axisMixin = new CssNameMixin<>(this);
    }
    return axisMixin;
}
 
Example #15
Source File: MaterialCard.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
protected CssNameMixin<MaterialCard, Axis> getAxisMixin() {
    if (axisMixin == null) {
        axisMixin = new CssNameMixin<>(this);
    }
    return axisMixin;
}
 
Example #16
Source File: MaterialCard.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
/**
 * Replace by {@link MaterialWidget#getOrientation()}
 */
@Deprecated
@Override
public Axis getAxis() {
    return getAxisMixin().getCssName();
}
 
Example #17
Source File: MaterialSplitPanel.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
/**
 * Get the axis orientation of splitter component.
 */
public Axis getAxis() {
    return options.orientation != null ? Axis.fromStyleName(options.orientation) : null;
}
 
Example #18
Source File: MaterialSplitPanel.java    From gwt-material-addins with Apache License 2.0 4 votes vote down vote up
/**
 * Set the axis orientation of splitter component (HORIZONTAL(Default) and VERTICAL).
 */
public void setAxis(Axis axis) {
    options.orientation = axis.getCssName();
}
 
Example #19
Source File: MaterialCard.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
/**
 * Replace by {@link MaterialWidget#setOrientation(Orientation)}
 * @param axis
 */
@Deprecated
@Override
public void setAxis(Axis axis) {
    getAxisMixin().setCssName(axis);
}
 
Example #20
Source File: MaterialFAB.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
protected CssNameMixin<MaterialFAB, Axis> getAxisMixin() {
    if (axisMixin == null) {
        axisMixin = new CssNameMixin<>(this);
    }
    return axisMixin;
}
 
Example #21
Source File: MaterialFAB.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
@Override
public Axis getAxis() {
    return getAxisMixin().getCssName();
}
 
Example #22
Source File: MaterialFAB.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
@Override
public void setAxis(Axis axis) {
    getAxisMixin().setCssName(axis);
}
 
Example #23
Source File: HasAxis.java    From gwt-material with Apache License 2.0 votes vote down vote up
void setAxis(Axis axis); 
Example #24
Source File: HasAxis.java    From gwt-material with Apache License 2.0 votes vote down vote up
Axis getAxis();