Skip to content

Commit

Permalink
Animation Framework Enhancements (#1966)
Browse files Browse the repository at this point in the history
* Add motion attribute to graph

* Enable Animations to run simultaneously

* Enhance ThrobNodesAnimation for better throb speed and size preservation

* Enhance FlyThrough for slower speed and reset to original view

* Enhance PanAnimation for slower speed

* Add smooth start and end to FlyThrough

* Prevent duplicate concurrent animations

* Enable concurrent animations across graphs

* Refactor Animation framework away from VisualChanges and towards graph modification

* Reset Flying animation on external camera modification

* Create VisualGraph attribute Motion and enable it to modify transaction line motion

* Mode direction indicator action to animation framework

* Enhance throb nodes to handle graph modification

* Enhance Animations

* Enhance FlyingAnimation to eliminate perspective issues when looking up

* Refactor flying animation to fly directly at nodes

* Fix code smells

* Ensure animations are interrupted at graph termination

* Assign Animations to respective VisualGraphTopComponent

* Fix code smells

* Enable users to disable animations

* Provide functionality where animations can complete in one step when disabled

* Fix code smells

* Enhance animation initialization failures

* Enhance GraphVisualAccess tests

* Enhance SVGGraphBuilder tests

* Enhance startAnimation logic

* Fix options Preferences Bundle issues resulting from merge conflict

* Create Color Warp Animation

* Pushing unfinished changes due to need for netbeans V3 update and repository re-clone

* Revert "Pushing unfinished changes due to need for netbeans V3 update and repository re-clone"

This reverts commit 3bc13a3.

* Prevent OpenGL Exception

* Implement review changes

* Ensure Animations stop on graph view close

* Fix build errors

* Add changes to change log

* Refactor menu base actions

* Update VisualGraphTopComponent.java

* Hide CONNECTION_MOTION attribute by making it META type, catch GLException

* Some optimisation, reducing number of objects etc

* Add SetColorValueOperation that extends GraphOperation to handle undo more efficiently on graph

* Update SetColorValuesOperation.java

* Update VisualConceptNGTest.java

Updating unit test because CONNECTION_MOTION was added as a graphAttribute of elementType META

* Create american_samoa.png

* Update to VisualGraphTopCOmponent and removal of unneeded dependency

* Add general animation help, update changelog

* Added unit tests for AnimationUtilities and AnimationManager

* Review updates, added MetaAttributes and unit test

* ColorWarpAnimation flashing fix and new unit tests

* Minor updates and unit tests added

* Some more review updates

* Unit test fixes

* Review updates

* Missed review updates

* Updated whatsnew and set Stop animation to stop for active graph only

* Fixed unit test and log handling in DefaultInteractionEventHandler

* Update DefaultInteractionEventHandler.java

* review updates + added unit tests

* Unit test fix

---------

Co-authored-by: andromeda-224 <ameda31224@gmail.com>
  • Loading branch information
capricornunicorn123 and andromeda-224 authored Jan 13, 2025
1 parent 013b62c commit 966636a
Show file tree
Hide file tree
Showing 66 changed files with 3,521 additions and 467 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
- Removed classes `VideoCreator` and `VideoFrame` from Core Utilities as they are unused.

## Changes in December 2024
- Refactored animation framework to update graph attributes and hold write locks for minimal durations to enable graph interction.
- Created Color Warp Animation.
- Enhanced Fly through and Direction Indicators Animation.
- Created Graph Connection Motion Attribute as a META graph element type.
- Created Animation setting to disable animations for low power machines.
- Created SetColorValuesOperation to save space on the undo/redo stack.
- Modified access of `VertexTypeIOProvider.writeTypeObject()` from public to private, reflecting current use and mirroring related classes and functions.
- Removed `CompositeStatus.getCompositeStatus()` which was unused.

Expand All @@ -14,6 +20,7 @@
- Removed `ColorblindUtilities.colorNodes()` which was unused. This behaviour is replicated in `VisualSchemaFactory.VisualSchema` with `applyColorblindVertex()` and `applyColorblindTransaction()`.
- Removed `ColorblindUtilities.setColorRef()` which only had one use. This behaviour is now directly added to where the function was previously used.
- Renamed `ColorblindUtilities.calcColorBrightness()` to `ColorblindUtilities.calculateColorBrightness()` for readability.
- Refactored MenuBaseAction to disable graph dependant menu items when primary graph is ambiguous.

## Changes in October 2024
- Added ability to pass parameters and selected items on graph to PluginReporter to display via `DefaultPluginInteraction`.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright 2010-2024 Australian Signals Directorate
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package au.gov.asd.tac.constellation.graph.operations;

import au.gov.asd.tac.constellation.graph.GraphElementType;
import au.gov.asd.tac.constellation.graph.GraphWriteMethods;
import au.gov.asd.tac.constellation.utilities.color.ConstellationColor;

/**
* The SetColorValuesOperation is used when the need arises to change a large
* number of ConstellationColor attribute values on an attribute of
* nodes/transactions on the graph, such as for animation. By implementing the
* color changes as a GraphOperation, significant space can be saved on the
* undo/redo stack.
*
* @author andromeda-224
*/
public class SetColorValuesOperation extends GraphOperation {

private final int attribute;
private final int capacity;
private int id;
protected ConstellationColor originalColor;
protected ConstellationColor newColor;
private final GraphWriteMethods graph;

/**
* Set up value initialisation.
* @param graph Graph to update
* @param elementType Element type to update
* @param attribute Attribute to update
*/
public SetColorValuesOperation(final GraphWriteMethods graph, final GraphElementType elementType, final int attribute) {
this.graph = graph;
this.attribute = attribute;
this.capacity = elementType.getElementCapacity(graph);
}

/**
* Set the new value to update if it has changed.
* @param elementId Id of element to update
* @param newValue New color to set attribute to
*/
public void setValue(final int elementId, final ConstellationColor newValue) {
this.id = elementId;
this.originalColor = graph.getObjectValue(attribute, id);
if (newValue != null
&& (newValue.getRGBString() == null ? originalColor.getRGBString() != null : !newValue.getRGBString().equals(originalColor.getRGBString()))) {
newColor = newValue;
}
}

@Override
public void execute(final GraphWriteMethods graph) {
if (newColor != null) {
graph.setObjectValue(attribute, id, newColor);
}
}

@Override
public void undo(final GraphWriteMethods graph) {
graph.setObjectValue(attribute, id, originalColor);
newColor = null;
}

@Override
public boolean isMoreEfficient() {
return true;
}

@Override
public int size() {
return capacity;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/*
* Copyright 2010-2024 Australian Signals Directorate
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package au.gov.asd.tac.constellation.graph.operations;

import au.gov.asd.tac.constellation.graph.GraphElementType;
import au.gov.asd.tac.constellation.graph.WritableGraph;
import au.gov.asd.tac.constellation.utilities.color.ConstellationColor;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

/**
*
* @author Andromeda-224
*/
public class SetColorValuesOperationNGTest {

private final ConstellationColor ORIGINAL_COLOR = ConstellationColor.CLOUDS;
private final ConstellationColor NEW_COLOR = ConstellationColor.CHOCOLATE;
private WritableGraph wg;
private final int ATTRIBUTEID = 101;
private final int ELEMENTID = 1;

public SetColorValuesOperationNGTest() {
}

@BeforeMethod
public void setUpMethod() throws Exception {
wg = mock(WritableGraph.class);
}

@AfterMethod
public void tearDownMethod() throws Exception {
}

/**
* Test of setValue method, of class SetColorValuesOperation.
*/
@Test
public void testSetValue() {
System.out.println("SetColorValuesOperation setValue");

SetColorValuesOperation instance = new SetColorValuesOperation(
wg, GraphElementType.VERTEX, ATTRIBUTEID);
doReturn(ORIGINAL_COLOR).when(wg).getObjectValue(ATTRIBUTEID, ELEMENTID);
instance.setValue(ELEMENTID, NEW_COLOR);
assertTrue(instance.originalColor == ORIGINAL_COLOR);
assertTrue(instance.newColor == NEW_COLOR);
}

/**
* Test of execute method, of class SetColorValuesOperation.
*/
@Test
public void testExecute() {
System.out.println("SetColorValuesOperation execute");
SetColorValuesOperation instance = new SetColorValuesOperation(
wg, GraphElementType.VERTEX, ATTRIBUTEID);
doReturn(ORIGINAL_COLOR).when(wg).getObjectValue(ATTRIBUTEID, ELEMENTID);

// new color not set, setObjectValue not called
assertTrue(instance.newColor == null);
instance.execute(wg);
verify(wg, times(0)).setObjectValue(ATTRIBUTEID, ELEMENTID, NEW_COLOR);

// set new color, setObjectValue called
instance.setValue(ELEMENTID, NEW_COLOR);
assertTrue(instance.originalColor == ORIGINAL_COLOR);
assertTrue(instance.newColor == NEW_COLOR);

instance.execute(wg);
verify(wg, times(1)).setObjectValue(ATTRIBUTEID, ELEMENTID, NEW_COLOR);
}

/**
* Test of undo method, of class SetColorValuesOperation.
*/
@Test
public void testUndo() {
System.out.println("SetColorValuesOperation undo");
SetColorValuesOperation instance = new SetColorValuesOperation(
wg, GraphElementType.VERTEX, ATTRIBUTEID);

// set the original color and new color
doReturn(ORIGINAL_COLOR).when(wg).getObjectValue(ATTRIBUTEID, ELEMENTID);
instance.setValue(ELEMENTID, NEW_COLOR);

assertTrue(instance.originalColor == ORIGINAL_COLOR);
assertTrue(instance.newColor == NEW_COLOR);

// undo => set object to original color and new color set to null
doNothing().when(wg).setObjectValue(ATTRIBUTEID, ELEMENTID, ORIGINAL_COLOR);
instance.undo(wg);
verify(wg, times(1)).setObjectValue(ATTRIBUTEID, ELEMENTID, ORIGINAL_COLOR);
assertTrue(instance.newColor == null);
}

/**
* Test of isMoreEfficient method, of class SetColorValuesOperation.
*/
@Test
public void testIsMoreEfficient() {
System.out.println("SetColorValuesOperation isMoreEfficient");
SetColorValuesOperation instance = new SetColorValuesOperation(
wg, GraphElementType.VERTEX, ATTRIBUTEID);
boolean expResult = true;
boolean result = instance.isMoreEfficient();
assertEquals(result, expResult);
}

/**
* Test of size method, of class SetColorValuesOperation.
*/
@Test
public void testSize() {
System.out.println("SetColorValuesOperation size");
doReturn(54).when(wg).getVertexCapacity();
SetColorValuesOperation instance = new SetColorValuesOperation(
wg, GraphElementType.VERTEX, ATTRIBUTEID);
int expResult = GraphElementType.VERTEX.getElementCapacity(wg);
int result = instance.size();
System.out.println(result);
assertEquals(result, expResult);
}
}
Loading

0 comments on commit 966636a

Please sign in to comment.