Search in sources :

Example 46 with TIntArrayList

use of gnu.trove.TIntArrayList in project android by JetBrains.

the class DeviceChooser method refreshTable.

private void refreshTable(IDevice[] devices) {
    final IDevice[] selectedDevices = getSelectedDevices(false);
    final TIntArrayList selectedRows = new TIntArrayList();
    for (int i = 0; i < devices.length; i++) {
        if (ArrayUtil.indexOf(selectedDevices, devices[i]) >= 0) {
            selectedRows.add(i);
        }
    }
    myProcessSelectionFlag = false;
    myDeviceTable.setModel(new MyDeviceTableModel(devices));
    if (selectedRows.size() == 0 && devices.length > 0) {
        myDeviceTable.getSelectionModel().setSelectionInterval(0, 0);
    }
    for (int selectedRow : selectedRows.toNativeArray()) {
        if (selectedRow < devices.length) {
            myDeviceTable.getSelectionModel().addSelectionInterval(selectedRow, selectedRow);
        }
    }
    fireSelectedDevicesChanged();
    myProcessSelectionFlag = true;
}
Also used : IDevice(com.android.ddmlib.IDevice) TIntArrayList(gnu.trove.TIntArrayList)

Example 47 with TIntArrayList

use of gnu.trove.TIntArrayList in project android by JetBrains.

the class StateChartVisualTest method populateUi.

@Override
protected void populateUi(@NotNull JPanel panel) {
    panel.setLayout(new BorderLayout());
    JLayeredPane timelinePane = createMockTimeline();
    panel.add(timelinePane, BorderLayout.CENTER);
    final JPanel controls = new JPanel();
    LayoutManager manager = new BoxLayout(controls, BoxLayout.Y_AXIS);
    controls.setLayout(manager);
    panel.add(controls, BorderLayout.WEST);
    final AtomicInteger networkVariance = new AtomicInteger(MockFruitState.values().length);
    final AtomicInteger radioVariance = new AtomicInteger(MockStrengthState.values().length);
    final AtomicInteger delay = new AtomicInteger(100);
    //TODO Refactor this to come from the DataStore, in the mean time we will leak a thread every time reset is called on this test.
    Thread updateDataThread = new Thread() {

        @Override
        public void run() {
            super.run();
            try {
                // Store off the last state to simulate the same preprocessing the DataStore does on each series.
                TIntArrayList lastNetworkData = new TIntArrayList();
                TIntArrayList lastRadioVariance = new TIntArrayList();
                while (true) {
                    long nowUs = TimeUnit.NANOSECONDS.toMicros(System.nanoTime());
                    int v = networkVariance.get();
                    for (int i = 0; i < mNetworkDataEntries.size(); i++) {
                        DefaultDataSeries<MockFruitState> series = mNetworkDataEntries.get(i);
                        if (Math.random() > 0.5f) {
                            int index = (int) (Math.random() * v);
                            if (lastNetworkData.size() <= i) {
                                lastNetworkData.add(-1);
                            }
                            if (lastNetworkData.get(i) != index) {
                                series.add(nowUs, MockFruitState.values()[index]);
                                lastNetworkData.set(i, index);
                            }
                        }
                    }
                    v = radioVariance.get();
                    for (int i = 0; i < mRadioDataEntries.size(); i++) {
                        DefaultDataSeries<MockStrengthState> series = mRadioDataEntries.get(i);
                        if (Math.random() > 0.5f) {
                            int index = (int) (Math.random() * v);
                            if (lastRadioVariance.size() <= i) {
                                lastRadioVariance.add(-1);
                            }
                            if (lastRadioVariance.get(i) != index) {
                                series.add(nowUs, MockStrengthState.values()[index]);
                                lastRadioVariance.set(i, index);
                            }
                        }
                    }
                    Thread.sleep(delay.get());
                }
            } catch (InterruptedException e) {
            }
        }
    };
    updateDataThread.start();
    controls.add(VisualTest.createVariableSlider("ArcWidth", 0, 100, new VisualTests.Value() {

        @Override
        public void set(int v) {
            mNetworkStatusChart.setArcWidth(v / 100f);
            mRadioStateChart.setArcWidth(v / 100f);
        }

        @Override
        public int get() {
            // unused
            return -1;
        }
    }));
    controls.add(VisualTest.createVariableSlider("ArcHeight", 0, 100, new VisualTests.Value() {

        @Override
        public void set(int v) {
            mNetworkStatusChart.setArcHeight(v / 100f);
            mRadioStateChart.setArcHeight(v / 100f);
        }

        @Override
        public int get() {
            // unused
            return -1;
        }
    }));
    controls.add(VisualTest.createVariableSlider("Gap", 0, 100, new VisualTests.Value() {

        @Override
        public void set(int v) {
            mNetworkStatusChart.setHeightGap(v / 100f);
            mRadioStateChart.setHeightGap(v / 100f);
        }

        @Override
        public int get() {
            // unused
            return -1;
        }
    }));
    controls.add(VisualTest.createVariableSlider("Delay", 10, 5000, new VisualTests.Value() {

        @Override
        public void set(int v) {
            delay.set(v);
        }

        @Override
        public int get() {
            return delay.get();
        }
    }));
    controls.add(VisualTest.createVariableSlider("Fruit Variance", 1, MockFruitState.values().length, new VisualTests.Value() {

        @Override
        public void set(int v) {
            networkVariance.set(v);
        }

        @Override
        public int get() {
            return networkVariance.get();
        }
    }));
    controls.add(VisualTest.createVariableSlider("Strength Variance", 1, MockStrengthState.values().length, new VisualTests.Value() {

        @Override
        public void set(int v) {
            radioVariance.set(v);
        }

        @Override
        public int get() {
            return radioVariance.get();
        }
    }));
    controls.add(VisualTest.createButton("Add Fruit Series", e -> {
        DefaultDataSeries<MockFruitState> networkSeries = new DefaultDataSeries<>();
        RangedSeries<MockFruitState> networkData = new RangedSeries(mTimeGlobalRangeUs, networkSeries);
        mNetworkStatusChart.addSeries(networkData);
        mNetworkDataEntries.add(networkSeries);
    }));
    controls.add(VisualTest.createButton("Add Strength Series", e -> {
        DefaultDataSeries<MockStrengthState> radioSeries = new DefaultDataSeries<>();
        RangedSeries<MockStrengthState> radioData = new RangedSeries(mTimeGlobalRangeUs, radioSeries);
        mRadioStateChart.addSeries(radioData);
        mRadioDataEntries.add(radioSeries);
    }));
    controls.add(VisualTest.createCheckbox("Shift xRange Min", itemEvent -> mAnimatedTimeRange.setShift(itemEvent.getStateChange() == ItemEvent.SELECTED)));
    controls.add(VisualTest.createCheckbox("Text Mode", itemEvent -> {
        StateChart.RenderMode mode = itemEvent.getStateChange() == ItemEvent.SELECTED ? StateChart.RenderMode.TEXT : StateChart.RenderMode.BAR;
        mNetworkStatusChart.setRenderMode(mode);
        mRadioStateChart.setRenderMode(mode);
    }));
    controls.add(new Box.Filler(new Dimension(0, 0), new Dimension(300, Integer.MAX_VALUE), new Dimension(300, Integer.MAX_VALUE)));
}
Also used : ItemEvent(java.awt.event.ItemEvent) Range(com.android.tools.adtui.model.Range) Arrays(java.util.Arrays) AxisComponent(com.android.tools.adtui.AxisComponent) DefaultDataSeries(com.android.tools.adtui.model.DefaultDataSeries) StateChart(com.android.tools.adtui.chart.StateChart) EnumMap(java.util.EnumMap) RangedSeries(com.android.tools.adtui.model.RangedSeries) Animatable(com.android.tools.adtui.Animatable) AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) ComponentEvent(java.awt.event.ComponentEvent) ArrayList(java.util.ArrayList) java.awt(java.awt) ComponentAdapter(java.awt.event.ComponentAdapter) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) AnimatedComponent(com.android.tools.adtui.AnimatedComponent) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NotNull(org.jetbrains.annotations.NotNull) TIntArrayList(gnu.trove.TIntArrayList) JBColor(com.intellij.ui.JBColor) javax.swing(javax.swing) RangedSeries(com.android.tools.adtui.model.RangedSeries) TIntArrayList(gnu.trove.TIntArrayList) DefaultDataSeries(com.android.tools.adtui.model.DefaultDataSeries) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Example 48 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-plugins by JetBrains.

the class SwfHighlightingTest method doHighlighting.

@NotNull
@Override
protected List<HighlightInfo> doHighlighting() {
    PsiDocumentManager.getInstance(myProject).commitAllDocuments();
    TIntArrayList toIgnore = new TIntArrayList();
    toIgnore.add(Pass.EXTERNAL_TOOLS);
    toIgnore.add(Pass.LOCAL_INSPECTIONS);
    toIgnore.add(Pass.WHOLE_FILE_LOCAL_INSPECTIONS);
    toIgnore.add(Pass.POPUP_HINTS);
    return CodeInsightTestFixtureImpl.instantiateAndRun(getFile(), getEditor(), toIgnore.toNativeArray(), false);
}
Also used : TIntArrayList(gnu.trove.TIntArrayList) NotNull(org.jetbrains.annotations.NotNull)

Example 49 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-plugins by JetBrains.

the class MovieSymbolTranscoder method processDefineSprite.

private void processDefineSprite(PlacedObject placedObject) throws IOException {
    buffer.position(placedObject.start + 4);
    final int endPosition = placedObject.start + placedObject.length;
    while (true) {
        final int tagStart = buffer.position();
        final int tagCodeAndLength = buffer.getShort();
        final int type = tagCodeAndLength >> 6;
        int length = tagCodeAndLength & 0x3F;
        if (length == 63) {
            length = buffer.getInt();
        }
        final int start = buffer.position();
        switch(type) {
            case TagTypes.DoAction:
            case TagTypes.DoInitAction:
                placedObject.prepareSparseWrite();
                if (placedObject.positions == null) {
                    placedObject.positions = new TIntArrayList();
                    placedObject.actualLength = placedObject.length;
                }
                placedObject.positions.add(tagStart);
                final int fullLength = length + (start - tagStart);
                placedObject.positions.add(tagStart + fullLength);
                placedObject.actualLength -= fullLength;
                continue;
            case TagTypes.PlaceObject:
            case TagTypes.PlaceObject3:
                throw new IOException("PlaceObject and PlaceObject3 are not supported");
            case TagTypes.PlaceObject2:
                processPlaceObject2(placedObject, length, start);
                break;
        }
        final int newPosition = start + length;
        if (newPosition < endPosition) {
            buffer.position(newPosition);
        } else {
            break;
        }
    }
}
Also used : IOException(java.io.IOException) TIntArrayList(gnu.trove.TIntArrayList)

Example 50 with TIntArrayList

use of gnu.trove.TIntArrayList in project intellij-plugins by JetBrains.

the class Encoder method functionTrait.

public void functionTrait(int kind, int name, int slotId, int methodInfo, int[] metadata) {
    currentBuffer.writeU32(history.getIndex(IndexHistory.MULTINAME, name));
    TIntArrayList newMetadata = trimMetadata(metadata);
    if (((kind >> 4) & TRAIT_FLAG_metadata) != 0 && newMetadata == null) {
        kind &= ~(TRAIT_FLAG_metadata << 4);
    }
    currentBuffer.writeU8(kind);
    currentBuffer.writeU32(slotId);
    currentBuffer.writeU32(this.methodInfo.getIndex(methodInfo));
    encodeMetaData(newMetadata);
}
Also used : TIntArrayList(gnu.trove.TIntArrayList)

Aggregations

TIntArrayList (gnu.trove.TIntArrayList)104 NotNull (org.jetbrains.annotations.NotNull)34 ArrayList (java.util.ArrayList)9 List (java.util.List)7 Nullable (org.jetbrains.annotations.Nullable)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ArrangementMatchingRulesControl (com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl)3 StringSearcher (com.intellij.util.text.StringSearcher)3 TIntHashSet (gnu.trove.TIntHashSet)3 TIntProcedure (gnu.trove.TIntProcedure)3 IOException (java.io.IOException)3 IDevice (com.android.ddmlib.IDevice)2 ArrangementMatchingRulesModel (com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesModel)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 Project (com.intellij.openapi.project.Project)2 TextRange (com.intellij.openapi.util.TextRange)2 ElementToWorkOn (com.intellij.refactoring.introduceField.ElementToWorkOn)2 IntroduceParameterProcessor (com.intellij.refactoring.introduceParameter.IntroduceParameterProcessor)2 RelativePoint (com.intellij.ui.awt.RelativePoint)2 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)2