Example usage for java.lang InstantiationException printStackTrace

List of usage examples for java.lang InstantiationException printStackTrace

Introduction

In this page you can find the example usage for java.lang InstantiationException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.hfoss.posit.android.api.fragment.ListFindsFragment.java

/**
 * Starts FindActivty or replaces second side in pane with FindFragment
 * for find creation.//from w ww  . j a  v  a2 s.c o m
 */
private void addFind() {
    if (mIsDualPane) {
        FindFragment findFragment = null;
        try {
            findFragment = (FindPluginManager.mFindPlugin.getmFindFragmentClass()).newInstance();
        } catch (java.lang.InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if (findFragment == null) {
            Toast.makeText(getActivity(), "can't create find fragment", Toast.LENGTH_LONG).show();
            return;
        }

        Bundle extras = new Bundle();
        extras.putString("ACTION", Intent.ACTION_INSERT);

        findFragment.setArguments(extras);

        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(R.id.find, findFragment);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.commit();
    } else {
        Intent intent = new Intent(getActivity(), FindPluginManager.mFindPlugin.getmFindActivityClass());
        intent.setAction(Intent.ACTION_INSERT);
        startActivity(intent);
    }
}

From source file:edu.umd.cs.guitar.ripper.WebRipperMonitor.java

@Override
public void setUp() {
    EventManager em = EventManager.getInstance();

    WebEventConfiguration eventConfig = new WebEventConfiguration();
    eventConfig.setNoNavigateHrefs(config.NO_NAVIGATE_HREFS);
    for (Class<? extends GEvent> event : WebConstants.DEFAULT_SUPPORTED_EVENTS) {
        try {/*  w ww .  ja  v  a  2  s.co m*/
            GEvent gevent = event.newInstance();
            if (gevent instanceof GEventConfigurable) {
                GEventConfigurable configurable = (GEventConfigurable) gevent;
                configurable.configure(eventConfig);
            }
            em.registerEvent(gevent);
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    if (config.PROFILE != null) {
        GUITARLog.Info("Configuring Firefox WebDriver to use desired profile name. "
                + "If the program exits prematurely at this point, then the profile does not"
                + "exist. Check your Firefox profiles directory, or open the Firefox profile"
                + "manager to create a new profile.");
        System.setProperty("webdriver.firefox.profile", config.PROFILE);
        GUITARLog.Info("Profile found.");
    }
    System.out.println("Browser : " + config.BROWSER);
    if (config.BROWSER == null || config.BROWSER == WebRipperConfiguration.Browser.Firefox) {
        driver = new FirefoxDriver();
        GUITARLog.Info("Driver set to: FirefoxDriver()"); //DEBUG
    } else if (config.BROWSER == WebRipperConfiguration.Browser.Chrome) {
        if (config.BROWSER_PATH != null)
            System.setProperty("webdriver.chrome.bin", config.BROWSER_PATH);
        driver = new ChromeDriver();
    } else if (config.BROWSER == WebRipperConfiguration.Browser.HTMLUnit) {
        driver = new HtmlUnitDriver();
    } else {
        driver = new InternetExplorerDriver();
    }

    driverHtml = new HtmlUnitDriver();
    GUITARLog.Info("HMTL Driver set to: HtmlUnitDriver()");

    handler = new WebWindowHandler((RemoteWebDriver) driver);
    handler.setUp();

    GUITARLog.Info("Handler setup.");

    widths = new ArrayList<Integer>();
    dotGraph = new WebDot();

    if (ripper != null)
        ripper.addComponentFilter(new WebExpandFilter());
    else
        GUITARLog.Info("Ripper in WebRipperMonitor has not been assigned.");
}

From source file:com.us.listener.ScheduleInitListener.java

public void doWork() {
    log.info("?");
    Set<String> paks = getPackgeList();
    log.info("?" + paks);
    try {//from  w ww .j  av  a2 s.com
        SCHEDULER = StdSchedulerFactory.getDefaultScheduler();
        for (String pak : paks) {
            Set<Class<?>> allClass = ClassUtil.getClassesByPackage(pak, true);
            for (Class<?> clazz : allClass) {
                try {
                    final Object jobInstance = clazz.newInstance();
                    if (jobInstance instanceof UsJob) {
                        UsJob job = (UsJob) jobInstance;
                        if (!job.isDisable()) {
                            Trigger trigger = job.initTrigger();
                            if (trigger.getName() == null) {
                                trigger.setName(jobInstance.getClass().getName());
                            }
                            log.info(String.format("Class[%s],Trigger:[%s]",
                                    jobInstance.getClass().getName(), trigger.getName()));
                            SCHEDULER.scheduleJob(job.makeJob(), trigger);
                        }
                    }
                } catch (InstantiationException e) {
                    log.error("??" + e.getMessage());
                } catch (IllegalAccessException e) {
                    log.error("??" + e.getMessage());
                }
            }
        }
        SCHEDULER.start();
        log.info("??");
    } catch (SchedulerException e) {
        e.printStackTrace();
    }
}

From source file:keel.Algorithms.Neural_Networks.NNEP_Common.neuralnet.AbstractNeuralNet.java

/**
 * <p>/*  w ww. j  ava  2s . c om*/
 * Returns a copy of this neural net
 * </p>
 * @return INeuralNet Copy of this neural net
 */
public INeuralNet copy() {

    // Resulting neural net
    AbstractNeuralNet result = null;

    try {
        result = this.getClass().newInstance();

        // Copy the input layer
        result.inputLayer = this.inputLayer.copy();

        // Copy hidden layers
        ILayer<? extends INeuron> lastCopiedLayer = result.inputLayer;
        for (LinkedLayer hl : this.hiddenLayers) {
            // Copy hidden layer
            LinkedLayer hlr = hl.copy(lastCopiedLayer);
            result.addHlayer(hlr);

            // Update last copied layer
            lastCopiedLayer = hlr;
        }

        // Copy the output layer
        result.outputLayer = this.outputLayer.copy(lastCopiedLayer);
    } catch (InstantiationException e) {
        System.out.println("Instantiation Error " + e.getLocalizedMessage());
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        System.out.println("Illegal Access Error " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    return result;
}

From source file:org.protorabbit.json.DefaultSerializer.java

public Object deSerialize(String jsonText, Class<?> targetClass) {
    if (jsonText == null) {
        return null;
    }//from  w  ww . j  a  v a 2 s.com
    // check for array
    jsonText = jsonText.trim();
    if (jsonText.startsWith("[")) {
        try {
            JSONArray ja = new JSONArray(jsonText);

            List<Object> jal = new ArrayList<Object>();

            for (int i = 0; i < ja.length(); i++) {
                try {
                    Object jao = ja.get(i);
                    Object targetObject = targetClass.newInstance();
                    deSerialize(jao, targetObject);
                    jal.add(targetObject);
                } catch (InstantiationException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }
            return jal;
        } catch (JSONException jex) {
            throw new RuntimeException("Error Parsing JSON:" + jex);
        }
        // check for object
    } else if (jsonText.startsWith("{")) {
        try {
            Object o = targetClass.newInstance();
            deSerialize(jsonText, o);
            return o;
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    } else {
        throw new RuntimeException("Error : Can only deserialize JSON objects or JSON arrays");
    }
    return null;
}

From source file:TreeColapse.java

@SuppressWarnings("unchecked")
public TreeColapse() throws IOException {

    // create a simple graph for the demo
    graph = new DelegateForest<Node, Integer>();

    createTree();//www .  j av a2  s.c  o m

    layout = new TreeLayout<Node, Integer>(graph);
    collapser = new TreeCollapser();

    radialLayout = new RadialTreeLayout<Node, Integer>(graph);
    radialLayout.setSize(new Dimension(600, 600));
    vv = new VisualizationViewer<Node, Integer>(layout, new Dimension(600, 600));
    vv.setBackground(Color.white);
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
    //vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Node>());
    vv.getRenderContext().setVertexLabelTransformer(new Transformer<Node, String>() {
        public String transform(Node e) {
            return (e.getName());
        }
    });

    vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction());
    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());
    vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
    rings = new Rings();

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(graphMouse.getModeListener());
    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JToggleButton radial = new JToggleButton("Radial");
    radial.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                // layout.setRadial(true);
                vv.setGraphLayout(radialLayout);
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {
                // layout.setRadial(false);
                vv.setGraphLayout(layout);
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.removePreRenderPaintable(rings);
            }
            vv.repaint();
        }
    });

    JButton collapse = new JButton("Collapse");
    collapse.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Collection picked = new HashSet(vv.getPickedVertexState().getPicked());
            if (picked.size() == 1) {
                Object root = picked.iterator().next();
                Forest inGraph = (Forest) layout.getGraph();

                try {
                    collapser.collapse(vv.getGraphLayout(), inGraph, root);
                } catch (InstantiationException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (IllegalAccessException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }

                vv.getPickedVertexState().clear();
                vv.repaint();
            }
        }
    });

    JButton expand = new JButton("Expand");
    expand.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Collection picked = vv.getPickedVertexState().getPicked();
            for (Object v : picked) {
                if (v instanceof Forest) {
                    Forest inGraph = (Forest) layout.getGraph();
                    collapser.expand(inGraph, (Forest) v);
                }
                vv.getPickedVertexState().clear();
                vv.repaint();
            }
        }
    });

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));

    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(radial);
    controls.add(scaleGrid);
    controls.add(modeBox);
    controls.add(collapse);
    controls.add(expand);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:keel.Algorithms.Neural_Networks.NNEP_Common.NeuralNetIndividualSpecies.java

/**
 * <p>/*w  ww .  j a  va2s  . c  om*/
 * Generate topology of a INeuralNet
 * 
 * @param neuralNet New neural net genotype
 * </p>
 */

private void generateTopology(INeuralNet neuralNet) {
    //Input Layer
    InputLayer inputLayer = new InputLayer();
    neuralNet.setInputLayer(inputLayer);

    try {
        //Each hidden Layer
        for (int i = 0; i < nOfHiddenLayers; i++) {
            LinkedLayer hiddenLayer = (LinkedLayer) Class.forName(getHiddenLayerType(i)).newInstance();
            hiddenLayer.setType(LinkedLayer.HIDDEN_LAYER);
            neuralNet.addHlayer(hiddenLayer);
        }

        //Output Layer
        LinkedLayer outputLayer = (LinkedLayer) Class.forName(getOutputLayerType()).newInstance();
        outputLayer.setType(LinkedLayer.OUTPUT_LAYER);
        neuralNet.setOutputLayer(outputLayer);

    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
}

From source file:ca.ualberta.cmput301.t03.MainActivity.java

public void changeNavigationTab(int id, boolean manuallyChangeSelection) {
    Fragment fragment = null;//from  w ww.  ja va2  s. c o m
    String title;
    Class fragmentClass;

    int index;
    switch (id) {
    case R.id.nav_inventory:
        fragmentClass = UserInventoryFragment.class;
        title = getString(R.string.inventoryTitle);
        index = 0;
        break;
    case R.id.nav_browse:
        fragmentClass = BrowseInventoryFragment.class;
        title = getString(R.string.browseTitle);
        index = 1;
        break;
    case R.id.nav_trades:
        fragmentClass = TradeOfferHistoryFragment.class;
        title = getString(R.string.tradeTitle);
        index = 2;
        break;
    case R.id.nav_friends:
        fragmentClass = FriendsListFragment.class;
        title = getString(R.string.friendsTitle);
        index = 3;
        break;
    case R.id.nav_edit_profile:
        fragmentClass = ViewProfileFragment.class;
        title = getString(R.string.myProfileLabel);
        index = 4;
        break;

    case R.id.nav_top_traders:
        fragmentClass = TopTradersFragment.class;
        title = getString(R.string.topTradersTitle);
        index = 5;
        break;

    default:
        fragmentClass = BrowseInventoryFragment.class;
        title = getString(R.string.browseTitle);
        index = 1;
        break;
    }

    try {
        fragment = (Fragment) fragmentClass.newInstance();
    } catch (InstantiationException e) {
        throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (Exception e) {
        e.printStackTrace();
    }
    fragmentManager.beginTransaction().replace(R.id.fragmentContent, fragment).commit();
    setTitle(title);

    if (manuallyChangeSelection) {
        navigationView.getMenu().getItem(index).setChecked(true);
    }
}

From source file:org.apache.hama.ml.perception.SmallMultiLayerPerceptron.java

@SuppressWarnings("rawtypes")
@Override/*from ww w  .  java  2 s .c  om*/
public void readFields(DataInput input) throws IOException {
    this.MLPType = WritableUtils.readString(input);
    this.learningRate = input.readDouble();
    this.regularization = input.readDouble();
    this.momentum = input.readDouble();
    this.numberOfLayers = input.readInt();
    this.squashingFunctionName = WritableUtils.readString(input);
    this.costFunctionName = WritableUtils.readString(input);

    this.squashingFunction = FunctionFactory.createDoubleFunction(this.squashingFunctionName);
    this.costFunction = FunctionFactory.createDoubleDoubleFunction(this.costFunctionName);

    // read the number of neurons for each layer
    this.layerSizeArray = new int[this.numberOfLayers];
    for (int i = 0; i < numberOfLayers; ++i) {
        this.layerSizeArray[i] = input.readInt();
    }
    this.weightMatrice = new DenseDoubleMatrix[this.numberOfLayers - 1];
    for (int i = 0; i < numberOfLayers - 1; ++i) {
        this.weightMatrice[i] = (DenseDoubleMatrix) MatrixWritable.read(input);
    }

    // read feature transformer
    int bytesLen = input.readInt();
    byte[] featureTransformerBytes = new byte[bytesLen];
    for (int i = 0; i < featureTransformerBytes.length; ++i) {
        featureTransformerBytes[i] = input.readByte();
    }
    Class featureTransformerCls = (Class) SerializationUtils.deserialize(featureTransformerBytes);
    Constructor constructor = featureTransformerCls.getConstructors()[0];
    try {
        this.featureTransformer = (FeatureTransformer) constructor.newInstance(new Object[] {});
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
}

From source file:treeai.Vertex.java

@SuppressWarnings("unchecked")
public JUNGTree() {

    // create a simple graph for the demo
    graph = new DelegateForest<Vertex, Integer>();

    createTree();/*from www.j a  va  2s.c om*/

    layout = new TreeLayout<Vertex, Integer>(graph);
    collapser = new TreeCollapser();

    radialLayout = new RadialTreeLayout<Vertex, Integer>(graph);
    radialLayout.setSize(new Dimension(600, 600));
    vv = new VisualizationViewer<Vertex, Integer>(layout, new Dimension(600, 600));
    vv.setBackground(Color.white);
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv.getRenderContext().setVertexShapeTransformer(new ClusterVertexShapeFunction());
    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());
    vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
    rings = new Rings();

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(graphMouse.getModeListener());
    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JToggleButton radial = new JToggleButton("Radial");
    radial.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                // layout.setRadial(true);
                vv.setGraphLayout(radialLayout);
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {
                // layout.setRadial(false);
                vv.setGraphLayout(layout);
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.removePreRenderPaintable(rings);
            }
            vv.repaint();
        }
    });

    JButton collapse = new JButton("Collapse");
    collapse.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Collection picked = new HashSet(vv.getPickedVertexState().getPicked());
            if (picked.size() == 1) {
                Object root = picked.iterator().next();
                Forest inGraph = (Forest) layout.getGraph();

                try {
                    collapser.collapse(vv.getGraphLayout(), inGraph, root);
                } catch (InstantiationException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (IllegalAccessException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }

                vv.getPickedVertexState().clear();
                vv.repaint();
            }
        }
    });

    JButton expand = new JButton("Expand");
    expand.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Collection picked = vv.getPickedVertexState().getPicked();
            for (Object v : picked) {
                if (v instanceof Forest) {
                    Forest inGraph = (Forest) layout.getGraph();
                    collapser.expand(inGraph, (Forest) v);
                }
                vv.getPickedVertexState().clear();
                vv.repaint();
            }
        }
    });

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));

    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(radial);
    controls.add(scaleGrid);
    controls.add(modeBox);
    controls.add(collapse);
    controls.add(expand);
    content.add(controls, BorderLayout.SOUTH);
}