@Override public void endElement(String uri, String localName, String qName) { depth--; if (depth == 1) { if (equalsOrSuffix(qName, "DiskSection")) { inDisk = false; builder.diskSection(diskHandler.getResult()); } else if (equalsOrSuffix(qName, "NetworkSection")) { inNetwork = false; builder.networkSection(networkHandler.getResult()); } else if (equalsOrSuffix(qName, "VirtualSystem")) { inVirtualSystem = false; builder.virtualSystem(virtualSystemHandler.getResult()); } else if (extensionHandlers.containsKey(qName)) { builder.additionalSection(qName, extensionHandler.getResult()); inExtensionSection = false; } else if (qName.endsWith("Section")) { builder.additionalSection(qName, defaultSectionHandler.getResult()); inSection = false; } } if (inDisk) { diskHandler.endElement(uri, localName, qName); } else if (inNetwork) { networkHandler.endElement(uri, localName, qName); } else if (inVirtualSystem) { virtualSystemHandler.endElement(uri, localName, qName); } else if (inExtensionSection) { extensionHandler.endElement(uri, localName, qName); } else if (inSection) { defaultSectionHandler.endElement(uri, localName, qName); } }
@Nullable public final T getValue(H h) { T data = h.getUserData(this); if (data == null) { data = myFunction.fun(h); h.putUserData(this, data == null ? (T) ObjectUtils.NULL : data); } return data == ObjectUtils.NULL ? null : data; }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (getItemViewType(position) == 0) { final H helper = getAdapterHelper(position, convertView, parent); convert(helper, getItem(position)); return helper.getView(); } return createIndeterminateProgressView(convertView, parent); }
private MethodMap(Class<?> clazz, HandlerMethod.Factory<H> factory) { final Map<Class<? extends Message>, Method> rawMethods = scan(clazz, factory.getPredicate()); final ImmutableMap.Builder<Class<? extends Message>, H> builder = ImmutableMap.builder(); for (Map.Entry<Class<? extends Message>, Method> entry : rawMethods.entrySet()) { final H handler = factory.create(entry.getValue()); factory.checkAccessModifier(handler.getMethod()); builder.put(entry.getKey(), handler); } this.map = builder.build(); }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (getItemViewType(position) == 0) { // 代表不是底部进度条 return createBottomProgressBar(convertView); } H adapterHelper = getHHLAdapterHelper(position, convertView, parent); T item = getItem(position); // 将helper和item绑定到一块 convert(adapterHelper, item); return adapterHelper.getView(); }
@Test @TestForIssue(jiraKey = "HHH-5472") public void testCascade() { A a = new A(); B b = new B(); C c = new C(); D d = new D(); E e = new E(); F f = new F(); G g = new G(); H h = new H(); a.getBCollection().add(b); b.setA(a); a.getCCollection().add(c); c.setA(a); b.getCCollection().add(c); c.setB(b); a.getDCollection().add(d); d.getACollection().add(a); d.getECollection().add(e); e.setF(f); f.getBCollection().add(b); b.setF(f); c.setG(g); g.getCCollection().add(c); f.setH(h); h.setG(g); Session s; s = openSession(); s.getTransaction().begin(); try { // Fails: says that C.b is null (even though it isn't). Doesn't fail if you persist c, g or h // instead of a s.persist(a); s.flush(); } finally { s.getTransaction().rollback(); s.close(); } }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs); depth++; if (depth == 2) { if (equalsOrSuffix(qName, "DiskSection")) { inDisk = true; } else if (equalsOrSuffix(qName, "NetworkSection")) { inNetwork = true; } else if (equalsOrSuffix(qName, "VirtualSystem")) { inVirtualSystem = true; } else if (extensionHandlers.containsKey(qName) || attributes.containsKey("type") && extensionHandlers.containsKey(attributes.get("type"))) { inExtensionSection = true; extensionHandler = extensionHandlers.get(qName).get(); } else if (qName.endsWith("Section")) { inSection = true; } } if (inDisk) { diskHandler.startElement(uri, localName, qName, attrs); } else if (inNetwork) { networkHandler.startElement(uri, localName, qName, attrs); } else if (inVirtualSystem) { virtualSystemHandler.startElement(uri, localName, qName, attrs); } else if (inExtensionSection) { extensionHandler.startElement(uri, localName, qName, attrs); } else if (inSection) { defaultSectionHandler.startElement(uri, localName, qName, attrs); } }
@Override public final <H extends RecordHandler<? super R>> H into(H handler) { for (R record : this) { handler.next(record); } return handler; }
@Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (LocationManager.HIGH_POWER_REQUEST_CHANGE_ACTION.equals(action)) { updateActiveLocationRequests(); } else if (LocationManager.MODE_CHANGED_ACTION.equals(action)) { mHandler.sendEmptyMessage(H.MSG_LOCATION_SETTINGS_CHANGED); } }
@Override protected void dump(FileDescriptor fd, PrintWriter fout, String[] args) { // No need to check for dump permission, since we only give this // interface to the system. CountDownLatch latch = new CountDownLatch(1); HandlerCaller.SomeArgs sargs = new HandlerCaller.SomeArgs(); sargs.arg1 = fd; sargs.arg2 = fout; sargs.arg3 = args; sargs.arg4 = latch; mH.sendMessage(mH.obtainMessage(MSG_DUMP, sargs)); try { if (!latch.await(5, TimeUnit.SECONDS)) { fout.println("Timeout waiting for dump"); } } catch (InterruptedException e) { fout.println("Interrupted waiting for dump"); } }
@Override public View getView(int position, View convertView, ViewGroup parent) { /*if (parent.getChildCount()==position) { final H helper = getAdapterHelper(position, convertView, parent); T item = getItem(position); convert(helper, item); helper.setAssociatedObject(item); return helper.getView(); }else { return convertView; }*/ if (getItemViewType(position) == 0) { final H helper = getAdapterHelper(position, convertView, parent); T item = getItem(position); convert(helper, item); helper.setAssociatedObject(item); return helper.getView(); } return createIndeterminateProgressView(convertView, parent); }
/** * If available, initializes the {@link DefaultLoginPageGeneratingFilter} shared object. * * @param http the {@link HttpSecurityBuilder} to use */ private void initDefaultLoginFilter(H http) { DefaultLoginPageGeneratingFilter loginPageGeneratingFilter = http.getSharedObject(DefaultLoginPageGeneratingFilter.class); if (loginPageGeneratingFilter != null && !isCustomLoginPage()) { loginPageGeneratingFilter.setFormLoginEnabled(true); loginPageGeneratingFilter.setUsernameParameter(getUsernameParameter()); loginPageGeneratingFilter.setPasswordParameter(getPasswordParameter()); loginPageGeneratingFilter.setLoginPageUrl(getLoginPage()); loginPageGeneratingFilter.setFailureUrl(getFailureUrl()); loginPageGeneratingFilter.setAuthenticationUrl(getLoginProcessingUrl()); } }
/** {@inheritDoc} */ @Override public void handleResult(final S result) { if (clientConnection.removePendingRequest(this)) { if (setResult(result)) { /* * FIXME: we must invoke the result handler even when * abandoned so that chained result handlers may clean up, * log, etc. We really need to signal that the result must * not be sent to the client. */ } resultHandler.handleResult(result); } }
@Override public void characters(char ch[], int start, int length) { if (inDisk) { diskHandler.characters(ch, start, length); } else if (inNetwork) { networkHandler.characters(ch, start, length); } else if (inVirtualSystem) { virtualSystemHandler.characters(ch, start, length); } else if (inExtensionSection) { extensionHandler.characters(ch, start, length); } else if (inSection) { defaultSectionHandler.characters(ch, start, length); } }
@Override public void runAlgorithm() throws InterruptedException { final HeapNode v = new HeapNode(H, K, ZDepth.ACTIONNODE); addToScene(v); setHeader("insertion"); if (H.getN() == 1000) { addStep("heapfull"); removeFromScene(v); return; } HeapNode w; // link H.setN(H.getN() + 1); final int n = H.getN(); int k = 1 << 10; if (n == 1) { H.setRoot(w = v); v.goToRoot(); pause(); } else { while ((k & n) == 0) { k >>= 1; } k >>= 1; w = H.getRoot(); while (k > 1) { w = ((n & k) == 0) ? w.getLeft() : w.getRight(); k >>= 1; } if ((k & n) == 0) { w.linkLeft(v); } else { w.linkRight(v); } v.mark(); H.reposition(); pause(); } removeFromScene(v); v.unmark(); // pause(); bubbleup(v); }
private < T extends AbstractEdmEntityImpl, G extends MongoTermList<T>, H extends AbstractRepresentationMigration<T>> boolean migratePhaseThree( JacksonDBCollection<G, String> termListColl_source, JacksonDBCollection<G, String> termListColl_target, H representationMagrition, ContextualCategory contextualCategory, int skip) throws UnknownHostException { int counter = 0; int interval = 0; while (true) { try { DBCursor<G> curs = termListColl_source .find(new BasicDBObject("entityType", contextualCategory.getEntityClass())) .skip(skip); curs.addOption(com.mongodb.Bytes.QUERYOPTION_NOTIMEOUT); while (curs.hasNext()) { G termList = curs.next(); counter++; interval++; if (interval == 1000) { System.out.println( String.format("Phase 3 (%s): %d ", contextualCategory.getEntityClass(), counter)); interval = 0; } String originalUri = termList.getCodeUri(); String codeUri = lookupOriginalCodeUri(termList.getCodeUri()); termList.setCodeUri(codeUri); termList.setId(null); String parent = termList.getParent(); if (StringUtils.isNotBlank(parent)) { String parentCodeUri = lookupOriginalCodeUri(parent); if (parentCodeUri == null) { termList.setParent(null); } else { termList.setParent(parentCodeUri); } } T representation = termList.getRepresentation(); representationMagrition.migrateRepresentation(codeUri, originalUri, representation); termList.setOwlSameAs(((PlaceImpl) representation).getOwlSameAs()); try { termListColl_target.insert(termList); } catch (DuplicateKeyException me) { continue; } } curs.close(); break; } catch (Exception e) { e.printStackTrace(); initialiseConnections(); counter--; skip = counter; continue; } } return true; }
public void cambiarModoMayus() { minusculas = !minusculas; if (minusculas) { Q.setText("q"); W.setText("w"); E.setText("e"); R.setText("r"); T.setText("t"); Y.setText("y"); U.setText("u"); I.setText("i"); O.setText("o"); P.setText("p"); A.setText("a"); S.setText("s"); D.setText("d"); F.setText("f"); G.setText("g"); H.setText("h"); J.setText("j"); K.setText("k"); L.setText("l"); N2.setText("ñ"); Z.setText("z"); X.setText("x"); C.setText("c"); V.setText("v"); B.setText("b"); N.setText("n"); M.setText("m"); } else { Q.setText("Q"); W.setText("W"); E.setText("E"); R.setText("R"); T.setText("T"); Y.setText("Y"); U.setText("U"); I.setText("I"); O.setText("O"); P.setText("P"); A.setText("A"); S.setText("S"); D.setText("D"); F.setText("F"); G.setText("G"); H.setText("H"); J.setText("J"); K.setText("K"); L.setText("L"); N2.setText("Ñ"); Z.setText("Z"); X.setText("X"); C.setText("C"); V.setText("V"); B.setText("B"); N.setText("N"); M.setText("M"); } }
public void postError(final Callable<?> task, Throwable error) { Message msg = h.obtainMessage(MSG_ERROR); msg.obj = new MessageData(task, error, null); h.sendMessage(msg); }
public void postCancel(final Callable<?> task) { Message msg = h.obtainMessage(MSG_CANCEL); msg.obj = new MessageData(task, null, null); h.sendMessage(msg); }
public void postStart(final Callable<?> task) { Message msg = h.obtainMessage(MSG_START); msg.obj = new MessageData(task, null, null); h.sendMessage(msg); }
public void postFinish(final Callable<?> task, Object result) { Message msg = h.obtainMessage(MSG_FINISH); msg.obj = new MessageData(task, result, null); h.sendMessage(msg); }
@Override public void onExitConditionChanged(Condition exitCondition) { mHandler.obtainMessage(H.EXIT_CONDITION_CHANGED, exitCondition).sendToTarget(); }
public void postSchedule(final Callable<?> task, final String queue) { Message msg = h.obtainMessage(MSG_SCHEDULE); msg.obj = new MessageData(task, null, queue); h.sendMessage(msg); }
@Override protected void encode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception { ByteBuf buf = null; if (msg instanceof HttpMessage) { if (state != ST_INIT) { throw new IllegalStateException( "unexpected message type: " + StringUtil.simpleClassName(msg)); } @SuppressWarnings({"unchecked", "CastConflictsWithInstanceof"}) H m = (H) msg; buf = ctx.alloc().buffer(); // Encode the message. encodeInitialLine(buf, m); HttpHeaders.encode(m.headers(), buf); buf.writeBytes(CRLF); state = HttpHeaders.isTransferEncodingChunked(m) ? ST_CONTENT_CHUNK : ST_CONTENT_NON_CHUNK; } if (msg instanceof HttpContent || msg instanceof ByteBuf || msg instanceof FileRegion) { if (state == ST_INIT) { throw new IllegalStateException( "unexpected message type: " + StringUtil.simpleClassName(msg)); } int contentLength = contentLength(msg); if (state == ST_CONTENT_NON_CHUNK) { if (contentLength > 0) { if (buf != null && buf.writableBytes() >= contentLength && msg instanceof HttpContent) { // merge into other buffer for performance reasons buf.writeBytes(((HttpContent) msg).content()); out.add(buf); } else { if (buf != null) { out.add(buf); } out.add(encodeAndRetain(msg)); } } else { if (buf != null) { out.add(buf); } else { // Need to produce some output otherwise an // IllegalStateException will be thrown out.add(EMPTY_BUFFER); } } if (msg instanceof LastHttpContent) { state = ST_INIT; } } else if (state == ST_CONTENT_CHUNK) { if (buf != null) { out.add(buf); } encodeChunkedContent(ctx, msg, contentLength, out); } else { throw new Error(); } } else { if (buf != null) { out.add(buf); } } }
private void HActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_HActionPerformed // TODO add your handling code here: actualizaCampo(H.getText()); } // GEN-LAST:event_HActionPerformed
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { teclado_base = new javax.swing.JPanel(); H = new javax.swing.JButton(); F = new javax.swing.JButton(); G = new javax.swing.JButton(); S = new javax.swing.JButton(); D = new javax.swing.JButton(); P = new javax.swing.JButton(); A = new javax.swing.JButton(); I = new javax.swing.JButton(); O = new javax.swing.JButton(); K = new javax.swing.JButton(); J = new javax.swing.JButton(); L = new javax.swing.JButton(); N2 = new javax.swing.JButton(); Z = new javax.swing.JButton(); X = new javax.swing.JButton(); C = new javax.swing.JButton(); V = new javax.swing.JButton(); B = new javax.swing.JButton(); N = new javax.swing.JButton(); Q = new javax.swing.JButton(); U = new javax.swing.JButton(); M = new javax.swing.JButton(); T = new javax.swing.JButton(); R = new javax.swing.JButton(); E = new javax.swing.JButton(); Espacio = new javax.swing.JButton(); W = new javax.swing.JButton(); Y = new javax.swing.JButton(); H.setText("H"); H.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { HActionPerformed(evt); } }); F.setText("F"); F.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { FActionPerformed(evt); } }); G.setText("G"); G.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { GActionPerformed(evt); } }); S.setText("S"); S.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SActionPerformed(evt); } }); D.setText("D"); D.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DActionPerformed(evt); } }); P.setText("P"); P.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { PActionPerformed(evt); } }); A.setText("A"); A.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AActionPerformed(evt); } }); I.setText("I"); I.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { IActionPerformed(evt); } }); O.setText("O"); O.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { OActionPerformed(evt); } }); K.setText("K"); K.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { KActionPerformed(evt); } }); J.setText("J"); J.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { JActionPerformed(evt); } }); L.setText("L"); L.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { LActionPerformed(evt); } }); N2.setText("Ñ"); N2.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { N2ActionPerformed(evt); } }); Z.setText("Z"); Z.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ZActionPerformed(evt); } }); X.setText("X"); X.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { XActionPerformed(evt); } }); C.setText("C"); C.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CActionPerformed(evt); } }); V.setText("V"); V.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { VActionPerformed(evt); } }); B.setText("B"); B.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BActionPerformed(evt); } }); N.setText("N"); N.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { NActionPerformed(evt); } }); Q.setText("Q"); Q.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { QActionPerformed(evt); } }); U.setText("U"); U.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { UActionPerformed(evt); } }); M.setText("M"); M.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { MActionPerformed(evt); } }); T.setText("T"); T.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { TActionPerformed(evt); } }); R.setText("R"); R.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { RActionPerformed(evt); } }); E.setText("E"); E.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EActionPerformed(evt); } }); Espacio.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EspacioActionPerformed(evt); } }); W.setText("W"); W.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { WActionPerformed(evt); } }); Y.setText("Y"); Y.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { YActionPerformed(evt); } }); javax.swing.GroupLayout teclado_baseLayout = new javax.swing.GroupLayout(teclado_base); teclado_base.setLayout(teclado_baseLayout); teclado_baseLayout.setHorizontalGroup( teclado_baseLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( teclado_baseLayout .createSequentialGroup() .addContainerGap() .addGroup( teclado_baseLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( teclado_baseLayout .createSequentialGroup() .addGroup( teclado_baseLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup( teclado_baseLayout .createSequentialGroup() .addComponent( Q, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent( W, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent( E, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .UNRELATED) .addComponent( R, javax.swing.GroupLayout.DEFAULT_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup( teclado_baseLayout .createSequentialGroup() .addComponent( A, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent( S, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent( D, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( F, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( teclado_baseLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent( G, javax.swing.GroupLayout.DEFAULT_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( T, javax.swing.GroupLayout.DEFAULT_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( teclado_baseLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent( H, javax.swing.GroupLayout.DEFAULT_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( Y, javax.swing.GroupLayout.DEFAULT_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( teclado_baseLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent( J, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( U, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( teclado_baseLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent( K, javax.swing.GroupLayout.DEFAULT_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( I, javax.swing.GroupLayout.DEFAULT_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( teclado_baseLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent( L, javax.swing.GroupLayout.DEFAULT_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( O, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( teclado_baseLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent( N2, javax.swing.GroupLayout.DEFAULT_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( P, javax.swing.GroupLayout.DEFAULT_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup( teclado_baseLayout .createSequentialGroup() .addComponent( Z, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( teclado_baseLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent( Espacio, javax.swing.GroupLayout.DEFAULT_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup( teclado_baseLayout .createSequentialGroup() .addComponent( X, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent( C, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent( V, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent( B, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent( N, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent( M, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); teclado_baseLayout.setVerticalGroup( teclado_baseLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( teclado_baseLayout .createSequentialGroup() .addGap(41, 41, 41) .addGroup( teclado_baseLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( teclado_baseLayout .createSequentialGroup() .addComponent( Q, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(10, 10, 10)) .addGroup( teclado_baseLayout .createSequentialGroup() .addComponent( W, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(11, 11, 11)) .addGroup( teclado_baseLayout .createSequentialGroup() .addGroup( teclado_baseLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent( E, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( R, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( T, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( Y, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( U, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( I, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( O, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( P, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18))) .addGroup( teclado_baseLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent( A, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( S, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( D, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup( teclado_baseLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent( G, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( F, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent( H, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( J, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( K, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( L, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( N2, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup( teclado_baseLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent( Z, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( X, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( C, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( V, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( B, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( N, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent( M, javax.swing.GroupLayout.DEFAULT_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, 39, Short.MAX_VALUE) .addComponent( Espacio, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(19, 19, 19))); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent( teclado_base, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent( teclado_base, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); } // </editor-fold>//GEN-END:initComponents
public boolean Battle() throws IOException { player.update(); boolean alive = true; int health; flee = false; P_HEALTH = player.getHealth(); PC_HEALTH = player.getCHealth(); plevel = player.getLevel(); elevel = elgen.nextInt(2) + (plevel - 1); if (elevel != -1) { health = 70 + (elevel) * 30; } else { health = 70; elevel = 0; } E_HEALTH = health; EC_HEALTH = health; H.pln("You have encountered a level " + elevel + " enemy"); while (EC_HEALTH > 0 && PC_HEALTH > 0 && !flee) { engine = new Random(); H.pln("Your Health: " + PC_HEALTH + "/" + P_HEALTH); H.pln("Enemy's Health : " + EC_HEALTH + "/" + E_HEALTH); H.pln("What do you want to do?"); H.pln("(1)Attack, (2)Defend, (3)Flee"); choice = H.inputInt(); switch (choice) { case 1: if (engine.nextInt(99) + 1 <= 95) { damage = (int) ((engine.nextInt(P_MAX_DAMAGE[plevel])) * wD[player.getWeapon()]); if (damage <= EC_HEALTH) { H.pln("Enemy lost " + damage + " health!"); EC_HEALTH -= damage; } else { helper = EC_HEALTH; H.pln("Enemy lost " + helper + " health!"); EC_HEALTH -= damage; } } else { if (plevel <= 8) { damage = (int) (engine.nextInt(P_MAX_DAMAGE[plevel + 2]) * wD[player.getWeapon()]); H.pln("Critical Hit!"); if (damage <= EC_HEALTH) { H.pln("Enemy lost " + damage + " health!"); EC_HEALTH -= damage; } else { helper = EC_HEALTH; H.pln("Enemy lost " + helper + " health!"); EC_HEALTH = 0; } } else { if (plevel == 9) { damage = (int) (engine.nextInt(P_MAX_DAMAGE[plevel + 1]) * wD[player.getWeapon()]); H.pln("Critical Hit!"); if (damage <= EC_HEALTH) { H.pln("Enemy lost " + damage + " health!"); EC_HEALTH -= damage; } else { helper = EC_HEALTH; H.pln("Enemy lost " + helper + " health!"); EC_HEALTH -= damage; } } if (plevel == 10) { damage = EC_HEALTH; H.pln("You destroyed the Enemy with one blow!!!"); } } } damage = engine.nextInt(E_MAX_DAMAGE[elevel]) + 1; H.pln("You lost " + damage + " health"); PC_HEALTH -= damage; player.setCHealth(PC_HEALTH); if (player.getCHealth() <= 0) return false; break; case 2: H.pln("You have blocked the enemy attack!"); break; case 3: H.pln("You have fled"); flee = true; break; } } if (EC_HEALTH <= 0 && PC_HEALTH > 0) { player.addXP(EC_HEALTH * (-1)); H.pln("You gained " + String.valueOf(EC_HEALTH * (-1)) + " XP!"); } if (flee) { player.addXP((EC_HEALTH) * (-1)); H.pln("You lost " + EC_HEALTH + " XP!"); } player.saveAll(); return true; }
public double h(double v) throws Exception { double v1 = h1.h(v); double v2 = h2.h(v); return Math.pow(v1, v2); }
protected CorrelationHandlerSpec(H messageHandler) { super(messageHandler); messageHandler.setForceReleaseAdviceChain(this.forceReleaseAdviceChain); }
@Override public void onConditionsChanged(Condition[] conditions) { mHandler.obtainMessage(H.UPDATE_CONDITIONS, conditions).sendToTarget(); }