Skip to content

Commit

Permalink
fix many issues with link, add pure java version (#484)
Browse files Browse the repository at this point in the history
* fix many issues with link, add pure java version

* small cleanup

* resolve comments
  • Loading branch information
jafu888 committed Jan 12, 2022
1 parent 55567b5 commit ec1348f
Show file tree
Hide file tree
Showing 23 changed files with 2,107 additions and 431 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions desktop/ConstraintLayoutInspector/.idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified desktop/ConstraintLayoutInspector/Link.jar
Binary file not shown.
Expand Up @@ -16,18 +16,13 @@
package androidx.constraintLayout.desktop.constraintRendering.layout3d;


import androidx.constraintLayout.desktop.link.LayoutView;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.prefs.Preferences;

import java.util.List;
import androidx.constraintLayout.desktop.link.*;

/**
* This is a simple test driver for the 3d engine
Expand Down Expand Up @@ -81,6 +76,7 @@ public static Layout.Widget getTestViews(BufferedImage img) {
return v;
}


private void savePref() {
Preferences prefs = Preferences.userNodeForPackage(CheckLayout3d.class);
final String ORIENTATION = "name_of_preference";
Expand Down Expand Up @@ -115,10 +111,11 @@ public static void create(Layout.Widget views, BufferedImage img) {
}


public static Layout.Widget get3dWidgets(ArrayList<LayoutView.Widget> widgets) {
public static Layout.Widget get3dWidgets(List<Widget> widgets) {

Layout.Widget rw = null;
for (LayoutView.Widget widget : widgets) {

for (Widget widget : widgets) {
float top = widget.getInterpolated().top;
float bottom = widget.getInterpolated().bottom;
float left = widget.getInterpolated().left;
Expand All @@ -133,7 +130,7 @@ public static Layout.Widget get3dWidgets(ArrayList<LayoutView.Widget> widgets) {
return null;
}
float z = 0;
for (LayoutView.Widget widget : widgets) {
for (Widget widget : widgets) {
float top = widget.getInterpolated().top;
float bottom = widget.getInterpolated().bottom;
float left = widget.getInterpolated().left;
Expand All @@ -151,12 +148,13 @@ public static Layout.Widget get3dWidgets(ArrayList<LayoutView.Widget> widgets) {
}

BufferedImage img;
public void update(ArrayList<LayoutView.Widget> widgets) {

public void update(List<Widget> widgets) {
myDisplay3D.updateTriData(new Layout(img, get3dWidgets(widgets)));
myDisplay3D.isImageInvalid = true;
myDisplay3D.repaint();
}
public static CheckLayout3d create3d(ArrayList<LayoutView.Widget> widgets) {
public static CheckLayout3d create3d(List<Widget> widgets) {
JFrame f = new JFrame("CheckTriangles");
CheckLayout3d p = new CheckLayout3d();
f.setContentPane(p);
Expand Down
@@ -0,0 +1,25 @@
/*
* Copyright 2021 The Android Open Source Project
*
* 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 androidx.constraintLayout.desktop.link;

import androidx.constraintlayout.core.parser.CLElement;

public interface DesignSurfaceModification {
CLElement getElement(String name);

void updateElement(String name, CLElement content);
}

0 comments on commit ec1348f

Please sign in to comment.